Skip to content

Commit 6eeaf0f

Browse files
davidsierradzFelipeLema
authored andcommitted
Add show_hidden_files_by_default option (hrsh7th#2)
MR requested at hrsh7th#66 (comment) Reviewed-on: https://codeberg.org/FelipeLema/cmp-async-path/pulls/2 Co-authored-by: davidsierradz <[email protected]> Co-committed-by: davidsierradz <[email protected]>
1 parent 89eb42f commit 6eeaf0f

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ Specify if directory names in the completion menu should include a trailing slas
5252
_Default:_ returns the current working directory of the current buffer
5353

5454
Specifies the base directory for relative paths.
55+
56+
### show_hidden_files_by_default (type: boolean)
57+
58+
_Default:_ `false`
59+
60+
Specify if hidden files should appear in the completion menu without the need of typing `.` first.

lua/cmp_async_path/init.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local constants = {max_lines = 20}
1212
---@field public trailing_slash boolean
1313
---@field public label_trailing_slash boolean
1414
---@field public get_cwd fun(table): string
15+
---@field public show_hidden_files_by_default boolean
1516

1617
---@type cmp_path.Option
1718
local defaults = {
@@ -20,6 +21,7 @@ local defaults = {
2021
get_cwd = function(params)
2122
return vim.fn.expand(('#%d:p:h'):format(params.context.bufnr))
2223
end,
24+
show_hidden_files_by_default = false,
2325
}
2426

2527
source.new = function() return setmetatable({}, {__index = source}) end
@@ -36,8 +38,8 @@ source.complete = function(self, params, callback)
3638
return callback()
3739
end
3840

39-
local include_hidden = string.sub(params.context.cursor_before_line,
40-
params.offset, params.offset) == '.'
41+
local include_hidden = option.show_hidden_files_by_default or
42+
string.sub(params.context.cursor_before_line, params.offset, params.offset) == '.'
4143
self:_candidates(dirname, include_hidden, option, function(err, candidates)
4244
if err then
4345
return callback()
@@ -211,6 +213,7 @@ source._validate_option = function(_, params)
211213
trailing_slash = {option.trailing_slash, 'boolean'},
212214
label_trailing_slash = {option.label_trailing_slash, 'boolean'},
213215
get_cwd = {option.get_cwd, 'function'},
216+
show_hidden_files_by_default = {option.show_hidden_files_by_default, 'boolean'},
214217
})
215218
return option
216219
end

0 commit comments

Comments
 (0)