|
22 | 22 | local function try_tool(tool, args, pattern, max, ignore_patterns) |
23 | 23 | if type(args) == 'function' then |
24 | 24 | local promise = args(pattern, max) |
25 | | - local result = promise and promise:wait() |
| 25 | + local result = promise and promise.and_then and promise:wait() |
26 | 26 |
|
27 | 27 | if result and type(result) == 'table' then |
28 | 28 | return vim.tbl_filter(should_keep(ignore_patterns), result) |
29 | 29 | end |
30 | 30 | end |
31 | 31 |
|
32 | | - -- Handle string-based commands (CLI tools) |
33 | 32 | if vim.fn.executable(tool) then |
34 | 33 | pattern = vim.fn.shellescape(pattern) or '.' |
35 | 34 | local result = run_systemlist(tool .. string.format(args, pattern, max)) |
|
44 | 43 | ---@return string[] |
45 | 44 | local function find_files_fast(pattern) |
46 | 45 | local file_config = config.ui.completion.file_sources |
47 | | - local cli_tool = last_successful_tool or file_config.preferred_cli_tool or 'fd' |
| 46 | + local cli_tool = last_successful_tool or file_config.preferred_cli_tool or 'server' |
48 | 47 | local max = file_config.max_files or 10 |
49 | 48 | local ignore_patterns = file_config.ignore_patterns or {} |
50 | 49 |
|
51 | | - local tools_order = { 'fd', 'fdfind', 'rg', 'git', 'server' } |
| 50 | + local tools_order = { 'server', 'fd', 'fdfind', 'rg', 'git' } |
52 | 51 | local commands = { |
53 | 52 | fd = ' --type f --type l --full-path --color=never -E .git -E node_modules -i %s --max-results %d 2>/dev/null', |
54 | 53 | fdfind = ' --type f --type l --color=never -E .git -E node_modules --full-path -i %s --max-results %d 2>/dev/null', |
55 | 54 | rg = ' --files --no-messages --color=never | grep -i %s 2>/dev/null | head -%d', |
56 | 55 | git = ' ls-files --cached --others --exclude-standard | grep -i %s | head -%d', |
57 | | - server = function(pattern, max) |
| 56 | + server = function(pattern) |
58 | 57 | return require('opencode.state').api_client:find_files(pattern) |
59 | 58 | end, |
60 | 59 | } |
@@ -147,8 +146,6 @@ local file_source = { |
147 | 146 | ---Get the list of recent files |
148 | 147 | ---@return CompletionItem[] |
149 | 148 | function M.get_recent_files() |
150 | | - local project = require('opencode.config_file').get_opencode_project() |
151 | | - local max = config.ui.completion.file_sources.max_files |
152 | 149 | local api_client = require('opencode.state').api_client |
153 | 150 |
|
154 | 151 | local result = api_client:get_file_status():wait() |
|
0 commit comments