Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,9 @@ Specify if directory names in the completion menu should include a trailing slas
_Default:_ returns the current working directory of the current buffer

Specifies the base directory for relative paths.

### show_hidden_files_by_default (type: boolean)

_Default:_ `false`

Specify if hidden files should appear in the completion menu without the need of typing `.` first.
5 changes: 4 additions & 1 deletion lua/cmp_path/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ local constants = {
---@field public trailing_slash boolean
---@field public label_trailing_slash boolean
---@field public get_cwd fun(): string
---@field public show_hidden_files_by_default boolean

---@type cmp_path.Option
local defaults = {
Expand All @@ -21,6 +22,7 @@ local defaults = {
get_cwd = function(params)
return vim.fn.expand(('#%d:p:h'):format(params.context.bufnr))
end,
show_hidden_files_by_default = false,
}

source.new = function()
Expand All @@ -43,7 +45,7 @@ source.complete = function(self, params, callback)
return callback()
end

local include_hidden = string.sub(params.context.cursor_before_line, params.offset, params.offset) == '.'
local include_hidden = option.show_hidden_files_by_default or string.sub(params.context.cursor_before_line, params.offset, params.offset) == '.'
self:_candidates(dirname, include_hidden, option, function(err, candidates)
if err then
return callback()
Expand Down Expand Up @@ -198,6 +200,7 @@ source._validate_option = function(_, params)
trailing_slash = { option.trailing_slash, 'boolean' },
label_trailing_slash = { option.label_trailing_slash, 'boolean' },
get_cwd = { option.get_cwd, 'function' },
show_hidden_files_by_default = { option.show_hidden_files_by_default, 'boolean' },
})
return option
end
Expand Down