@@ -11,9 +11,14 @@ local sub = require('wincent.commandt.private.sub')
1111
1212local commandt = {}
1313
14- -- "Smart" open that will switch to an already open window containing the
15- -- specified `buffer`, if one exists; otherwise, it will open a new window using
16- -- `command` (which should be one of `edit`, `tabedit`, `split`, or `vsplit`).
14+ --- "Smart" open that will switch to an already open window containing the
15+ --- specified `buffer`, if one exists; otherwise, it will open a new window
16+ --- using `command` (which should be one of `edit`, `tabedit`, `split`, or
17+ --- `vsplit`).
18+ ---
19+ --- @param buffer string
20+ --- @param command ' edit' | ' split' | ' tabedit' | ' vsplit'
21+ --- @return nil
1722local function smart_open (buffer , command )
1823 buffer = vim .fn .fnameescape (buffer )
1924 local is_visible = require (' wincent.commandt.private.buffer_visible' )(buffer )
2833
2934local directory_stack = {}
3035
36+ --- Push a directory onto the stack.
37+ ---
38+ --- @param directory string
39+ --- @return nil
3140local function pushd (directory )
3241 table.insert (directory_stack , vim .uv .cwd ())
3342 vim .fn .chdir (directory )
3443end
3544
45+ --- Pop a directory from the stack.
46+ ---
47+ --- @return nil
3648local function popd ()
3749 local directory = table.remove (directory_stack )
3850 if directory then
3951 vim .fn .chdir (directory )
4052 end
4153end
4254
43- -- Common `on_directory` implementation that infers the appropriate directory if
44- -- none is explicitly provided.
55+ --- Common `on_directory` implementation that infers the appropriate directory
56+ --- if none is explicitly provided.
57+ ---
58+ --- @param directory string | nil
59+ --- @return string
4560local function on_directory (directory )
4661 if directory == ' ' or directory == nil then
4762 return commandt ._directory ()
@@ -341,11 +356,16 @@ local function force_dot_files(options)
341356 return options
342357end
343358
359+ --- @alias CandidatesFunction
360+ --- | fun(directory: string): string[]
361+ --- | # Function that returns a list of candidate strings
362+
344363local default_options = {
345364 always_show_dot_files = false ,
346365 finders = {
347366 -- Returns the list of paths currently loaded into buffers.
348367 buffer = {
368+ --- @type CandidatesFunction
349369 candidates = function (_directory )
350370 local handles = vim .api .nvim_list_bufs ()
351371 local paths = {}
0 commit comments