Skip to content

Commit a1999fe

Browse files
committed
Mark all the internal functions as private.
1 parent 23d1e0b commit a1999fe

File tree

2 files changed

+22
-151
lines changed

2 files changed

+22
-151
lines changed

autoload/maktaba/internal/plugin.vim

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ endfunction
8585

8686

8787
""
88+
" @private
8889
" Splits {dir} into canonical plugin name and parent directory, returning name.
8990
" If {dir} is in s:plugins_by_location, gets the name of the plugin there
9091
" instead.
@@ -213,6 +214,7 @@ endfunction
213214

214215

215216
""
217+
" @private
216218
" This function is used to both control when plugin files are entered, and get
217219
" a handle to the current plugin object. It should be called from the top of
218220
" an autoload/*.vim, plugin/*.vim, ftplugin/*.vim, or instant/*.vim file as
@@ -294,6 +296,7 @@ endfunction
294296

295297

296298
""
299+
" @private
297300
" Scans 'runtimepath' for any unregistered plugins and registers them with
298301
" maktaba. May trigger instant/ hooks for newly-registered plugins.
299302
function! maktaba#internal#plugin#Detect() abort
@@ -304,6 +307,7 @@ endfunction
304307

305308

306309
""
310+
" @private
307311
" A list of all installed plugins in alphabetical order.
308312
" Automatically detects unregistered plugins using @function(#Detect).
309313
function! maktaba#internal#plugin#RegisteredPlugins() abort
@@ -313,6 +317,7 @@ endfunction
313317

314318

315319
""
320+
" @private
316321
" 1 if {plugin} was registered with maktaba#plugin#Register.
317322
" This is more reliable for determining if a Maktaba compatible plugin by
318323
" the name of {plugin} was registered, but can not be used to dependency check
@@ -330,6 +335,7 @@ endfunction
330335

331336

332337
""
338+
" @private
333339
" The canonical name of {plugin}.
334340
" This is the name of the plugin directory with any "vim-" prefix or ".vim"
335341
" suffix stripped off: both "vim-unimpaired" and "unimpaired.vim" would become
@@ -346,6 +352,7 @@ endfunction
346352

347353

348354
""
355+
" @private
349356
" @usage dir [settings]
350357
" Installs the plugin located at {dir}. Installation entails adding the plugin
351358
" to the runtimepath, loading its flags.vim file, and sourcing any files in its
@@ -409,6 +416,7 @@ endfunction
409416

410417

411418
""
419+
" @private
412420
" Gets the plugin object associated with {plugin}. {plugin} may either be the
413421
" name of the plugin directory, or the canonicalized plugin name (with any
414422
" "vim-" prefix or ".vim" suffix stripped off). See @function(#CanonicalName).
@@ -438,6 +446,7 @@ endfunction
438446

439447

440448
""
449+
" @private
441450
" Installs the plugin located at {dir}, unless it already exists. The
442451
" appropriate maktaba plugin object is returned.
443452
"
@@ -662,6 +671,7 @@ endfunction
662671

663672

664673
""
674+
" @dict Plugin
665675
" Sources {file}, which should be a list specifying the location of a file from
666676
" the plugin root. For example, if you want to source plugin/commands.vim, call
667677
" this function on ['plugin', 'commands']. The referenced file will be sourced,

doc/maktaba.txt

Lines changed: 12 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,18 @@ Logger.Severe({message}, [args...]) *Logger.Severe()*
265265
The maktaba plugin object. Exposes functions that operate on the plugin
266266
itself.
267267

268+
Plugin.Source({file}, [optional]) *Plugin.Source()*
269+
Sources {file}, which should be a list specifying the location of a file
270+
from the plugin root. For example, if you want to source
271+
plugin/commands.vim, call this function on ['plugin', 'commands']. The
272+
referenced file will be sourced, if it exists. Otherwise, exceptions will be
273+
thrown, unless you set [optional]. If [optional] exists, this function
274+
returns whether or not the file was actually sourced.
275+
[optional] is 0 if omitted.
276+
Throws ERROR(BadValue) if {file} describes a directory.
277+
Throws ERROR(NotAuthorized) if {file} cannot be read.
278+
Throws ERROR(NotFound) if {file} does not describe a plugin file.
279+
268280
Plugin.Load([file], [optional]) *Plugin.Load()*
269281
If [file] is given, the plugin file plugin/<file>.vim will be sourced. An
270282
error will be thrown if [file] does not exist unless [optional] is set. If
@@ -1159,157 +1171,6 @@ maktaba#function#Sorted({list}, {func}) *maktaba#function#Sorted()*
11591171
Returns a new list that is a sorted copy of {list}. {func} is used to
11601172
determine the sort order, as in |sort()|.
11611173

1162-
maktaba#internal#plugin#Enter({file}) *maktaba#internal#plugin#Enter()*
1163-
This function is used to both control when plugin files are entered, and get
1164-
a handle to the current plugin object. It should be called from the top of
1165-
an autoload/*.vim, plugin/*.vim, ftplugin/*.vim, or instant/*.vim file as
1166-
follows:
1167-
>
1168-
let [s:plugin, s:enter] = maktaba#plugin#Enter(expand('<sfile>:p'))
1169-
if !s:enter
1170-
finish
1171-
endif
1172-
<
1173-
The result is a tuple containing the plugin object and a boolean specifying
1174-
whether the file should be entered (taking user preferences and whether the
1175-
file has already been sourced into account). If the second value is false,
1176-
the script should finish immediately.
1177-
1178-
autoload/*.vim files are entered on demand (see |autoload|), this function
1179-
only helps prevent re-entry.
1180-
1181-
For plugin/*.vim and instant/*.vim files, maktaba ensures that the file is
1182-
only entered once, and then only if the user has not disabled the file via
1183-
the plugin[*] or instant[*] flags.
1184-
1185-
In ftplugin/*.vim files, maktaba ensures that the file is loaded only once
1186-
per buffer.
1187-
1188-
Note that maktaba does NOT set the g:loaded_{plugin} variable, as
1189-
recommended in the write-plugin helpfiles. This is because maktaba plugins
1190-
may span multiple files, and there is no clear moment when the plugin is
1191-
"loaded". If you feel you must adhere to this convention, be sure to set the
1192-
appropriate g:loaded_* variable when appropriate.
1193-
1194-
maktaba#internal#plugin#Detect() *maktaba#internal#plugin#Detect()*
1195-
Scans 'runtimepath' for any unregistered plugins and registers them with
1196-
maktaba. May trigger instant/ hooks for newly-registered plugins.
1197-
1198-
maktaba#internal#plugin#RegisteredPlugins()
1199-
*maktaba#internal#plugin#RegisteredPlugins()*
1200-
A list of all installed plugins in alphabetical order. Automatically detects
1201-
unregistered plugins using |maktaba#internal#plugin#Detect()|.
1202-
1203-
maktaba#internal#plugin#IsRegistered({plugin})
1204-
*maktaba#internal#plugin#IsRegistered()*
1205-
1 if {plugin} was registered with maktaba#plugin#Register. This is more
1206-
reliable for determining if a Maktaba compatible plugin by the name of
1207-
{plugin} was registered, but can not be used to dependency check non-Maktaba
1208-
plugins. Detects plugins added to 'runtimepath' even if they haven't been
1209-
explicitly registered with maktaba.
1210-
1211-
maktaba#internal#plugin#CanonicalName({plugin})
1212-
*maktaba#internal#plugin#CanonicalName()*
1213-
The canonical name of {plugin}. This is the name of the plugin directory
1214-
with any "vim-" prefix or ".vim" suffix stripped off: both "vim-unimpaired"
1215-
and "unimpaired.vim" would become simply "unimpaired".
1216-
1217-
Note that plugins with different names in the filesystem can conflict in
1218-
maktaba. If you've loaded a plugin in the directory "plugins/vim-myplugin"
1219-
then maktaba can't handle a plugin named "plugins/myplugin". Make sure your
1220-
plugins have sufficiently different names!
1221-
1222-
maktaba#internal#plugin#Install({dir}, [settings])
1223-
*maktaba#internal#plugin#Install()*
1224-
Installs the plugin located at {dir}. Installation entails adding the plugin
1225-
to the runtimepath, loading its flags.vim file, and sourcing any files in
1226-
its instant/ directory.
1227-
1228-
Returns the maktaba plugin object describing the installed plugin.
1229-
1230-
{dir} should be the full path to the plugin directory. The plugin itself
1231-
should be the last component in the directory path. If the plugin doesn't
1232-
have an explicit name declared in addon-info.json, the plugin name will be
1233-
the name of this directory with all invalid characters converted to
1234-
underscores (see |maktaba#internal#plugin#CanonicalName()|).
1235-
1236-
If the plugin contains a plugin/ directory it will have a special "plugin"
1237-
dictionary flag that controls which plugin files are loaded. For example, if
1238-
the plugin contains plugin/commands.vim, you can use
1239-
>
1240-
let plugin = maktaba#plugin#Install(path)
1241-
call plugin.Flag('plugin[commands]', 0)
1242-
<
1243-
to disable it. More generally, "plugin" is a dictionary whose keys control
1244-
the loading of plugin files. A file's key is its filename without the '.vim'
1245-
extension. Set the key to 0 to prevent the file from loading or 1 to allow
1246-
it to load.
1247-
1248-
Note that setting the key to 1 only ALLOWS the file to load: if load time
1249-
has already passed, enabling the plugin file will not cause it to load. To
1250-
load plugin files late use |Plugin.Load|.
1251-
1252-
All plugin files are loaded by default EXCEPT the file plugin/mappings.vim,
1253-
which is opt-in. (Set plugin[mappings] to 1 to enable.)
1254-
1255-
If the plugin contains an instant/ directory it will also have a special
1256-
"instant" flag, which acts similarly to the special "plugin" flag for
1257-
instant/*.vim files. For example, in a plugin with an instant/earlyfile.vim,
1258-
the following DOES NOT WORK:
1259-
>
1260-
let plugin = maktaba#plugin#Install(path)
1261-
call plugin.Flag('instant[earlyfile]', 0)
1262-
<
1263-
All instant/*.vim files are sourced during installation. In order to
1264-
configure the "instant" flag, you must pass [settings] to the installation
1265-
function. If given, they must be a list of maktaba settings (see
1266-
|maktaba#setting#Create|). They will be applied after instant/flags.vim is
1267-
sourced (if present), but before any other instant files are sourced. For
1268-
example:
1269-
>
1270-
let noearly = maktaba#setting#Parse('instant[earlyfile]=0')
1271-
let plugin = maktaba#plugin#Install(path, [noearly])
1272-
<
1273-
Throws ERROR(BadValue) if {dir} is empty.
1274-
Throws ERROR(AlreadyExists) if the plugin already exists.
1275-
Throws ERROR(ConfigError) if [settings] cannot be applied to this plugin.
1276-
1277-
maktaba#internal#plugin#Get({plugin}) *maktaba#internal#plugin#Get()*
1278-
Gets the plugin object associated with {plugin}. {plugin} may either be the
1279-
name of the plugin directory, or the canonicalized plugin name (with any
1280-
"vim-" prefix or ".vim" suffix stripped off). See
1281-
|maktaba#internal#plugin#CanonicalName()|. Detects plugins added to
1282-
'runtimepath' even if they haven't been explicitly registered with maktaba.
1283-
Throws ERROR(NotFound) if the plugin object does not exist.
1284-
1285-
maktaba#internal#plugin#GetOrInstall({dir}, [settings])
1286-
*maktaba#internal#plugin#GetOrInstall()*
1287-
Installs the plugin located at {dir}, unless it already exists. The
1288-
appropriate maktaba plugin object is returned.
1289-
1290-
[settings], if given, must be a list of maktaba settings (see
1291-
|maktaba#setting#Create|). If the plugin is new, they will be applied as in
1292-
|maktaba#internal#plugin#Install()|. Otherwise, they will be applied before
1293-
returning the plugin object.
1294-
1295-
See also |maktaba#internal#plugin#Install()|.
1296-
Throws ERROR(AlreadyExists) if the existing plugin comes from a different
1297-
directory.
1298-
Throws ERROR(ConfigError) if [settings] cannot be applied to this plugin.
1299-
1300-
maktaba#internal#plugin#Source({file}, [optional])
1301-
*maktaba#internal#plugin#Source()*
1302-
Sources {file}, which should be a list specifying the location of a file
1303-
from the plugin root. For example, if you want to source
1304-
plugin/commands.vim, call this function on ['plugin', 'commands']. The
1305-
referenced file will be sourced, if it exists. Otherwise, exceptions will be
1306-
thrown, unless you set [optional]. If [optional] exists, this function
1307-
returns whether or not the file was actually sourced.
1308-
[optional] is 0 if omitted.
1309-
Throws ERROR(BadValue) if {file} describes a directory.
1310-
Throws ERROR(NotAuthorized) if {file} cannot be read.
1311-
Throws ERROR(NotFound) if {file} does not describe a plugin file.
1312-
13131174
maktaba#json#Format({value}) *maktaba#json#Format()*
13141175
Formats {value} as a JSON text. {value} may be any Vim value other than a
13151176
Funcref or non-finite Float (or a Dictionary or List containing either).

0 commit comments

Comments
 (0)