Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clap files <dir> do not anymore work in 0.45 #987

Closed
fievel opened this issue Jul 3, 2023 · 7 comments
Closed

Clap files <dir> do not anymore work in 0.45 #987

fievel opened this issue Jul 3, 2023 · 7 comments

Comments

@fievel
Copy link

fievel commented Jul 3, 2023

Since the update to vim-clap 0.45, the optional directory argument to files provider do not seems to work anymore and give the following message (for command :Clap files src src being a directory under my getcwd()):

vim-clap: using default FilesArgs { base: BaseArgs { query: None, cwd: None, no_cwd: false }, hidden: false, name_only: false, paths: [] } due to error: unexpected argument 'src' found^@^@Usage: :Clap files [OPTIONS]^@^@For more information, try '--help'.^@

Environment:

  • OS: Windows
  • Vim version: 9.0
  • vim-clap version: 0.45
  • Have you upgraded to/compiled the latest Rust binary: I use my own compiled version of maple
  • I use the setting let g:clap_disable_run_rooter = 1 but I also tried without

Clap debug

            has ctags: ctags not found
            has cargo: 1
            has maple: C:\Workdir\devtools\vimfiles\plugged\vim-clap/target/release/maple.exe
           maple info: version 0.1.45, compiled at: 2023-07-03 12:06:42.679091800 +02:00, built for x86_64-pc-windows-msvc by rustc 1.70.0 (90c541806 2023-05-31).

        rustc version: rustc 1.70.0 (90c541806 2023-05-31)

     Current FileType: vim
Third Party Providers: []
       Global Options:
    let g:clap#autoload_dir = 'C:\Workdir\devtools\vimfiles\plugged\vim-clap\autoload'
    let g:clap#popup#display = {'shrink': function('352'), 'open': function('<SNR>148_create_display'), 'width': 104, 'shrink_if_undersize': function('351')}
    let g:clap#popup#preview = {'line_count': function('<SNR>147__line_count'), 'show': function('353'), 'hide': function('354'), 'clear': function('355'), 'add_highlight': function('357'), 'get_lines': function('<SNR>147__get_lines'), 'getbufvar': function('<SNR>147__getbufvar'), 'setbufvar_batch': function('<SNR>147__setbufvar_batch'), 'setbufvar': function('<SNR>147__setbufvar'), 'winid': 1057, 'win_is_valid': function('<SNR>147__win_is_valid'), 'goto_win': function('<SNR>147__goto_win'), 'set_syntax': function('356'), 'bufnr': 11}
    let g:clap#provider_alias = {'gfiles': 'git_files', 'hist:': 'command_history', 'hist/': 'search_history'}
    let g:clap_actions = ['open-config', 'generate-toc', 'update-toc', 'delete-toc']
    let g:clap_background_shadow_blend = 50
    let g:clap_disable_bottom_top = 0
    let g:clap_disable_matches_indicator = v:false
    let g:clap_disable_run_rooter = 1
    let g:clap_enable_background_shadow = v:false
    let g:clap_enable_debug = v:false
    let g:clap_enable_icon = 0
    let g:clap_forerunner_status_sign = {'done': '•', 'running': '!', 'using_cache': '*'}
    let g:clap_indicator_winid = 1058
    let g:clap_insert_mode_only = v:false
    let g:clap_multi_selection_warning_silent = 0
    let g:clap_no_matches_msg = 'NO MATCHES FOUND'
    let g:clap_open_action = {'ctrl-v': 'vsplit', 'ctrl-x': 'split', 'ctrl-t': 'tab split'}
    let g:clap_open_preview = 'always'
    let g:clap_popup_border = 'rounded'
    let g:clap_preview_direction = 'AUTO'
    let g:clap_preview_size = 5
    let g:clap_project_root_markers = ['.svn', '.svn/', '.git', '.git/', '.root', 'init.def']
    let g:clap_providers_relaunch_code = '@@'
    let g:clap_search_box_border_style = 'curve'
    let g:clap_search_box_border_symbols = {'nil': ['', ''], 'curve': ['', ''], 'arrow': ['', '']}
    let g:clap_spinner_winid = 1060
  Provider Variables:
                     []
@fievel fievel added the bug Something isn't working label Jul 3, 2023
@liuchengxu
Copy link
Owner

Use :Clap files --path=src or :Clap files --path src, which is a breaking change in v0.45, see #981.

@liuchengxu liuchengxu removed the bug Something isn't working label Jul 3, 2023
@fievel
Copy link
Author

fievel commented Jul 3, 2023

Thanks, there is some documentation in clap-support.txt that needs to be updated then ;)

@liuchengxu
Copy link
Owner

Yeah, a bunch of docs are outdated, feel free to send a PR :P

@fievel
Copy link
Author

fievel commented Jul 3, 2023

Ok after having tested again (and tried to find a way to debug, but there does not seems to be a way), it appears that --path option is not behaving correctly for files provider (at least on windows). There is no error messages but all the files in the project root / working directory are shown and not only the one in the given path.
I tested giving path relative to root, absolute path, forward slashes instead of backslashes, escaping backslashes, giving the argument between quotes, using --path= vs --path but nothing seems to works.
Do you prefer to reopen this issue or to create a new one ?
I would be ok to see if I can fix it myself but this codebase is a bit complex and I would need to know how to debug interaction with the rust backend (see what goes in and out of it in order to be able to reproduce in cli for example).

@liuchengxu
Copy link
Owner

liuchengxu commented Jul 4, 2023

all the files in the project root / working directory are shown and not only the one in the given path.

Okay, I see, you need :Clap files --no-cwd --path src. Feel free to re-open if this is not the answer you are looking for. In addition, looks like I need to update the issue #981 with more details, feel free to ask there so that we have a central place to this breaking change, I'm open to suggestions as well.

If you want to hack the codebase, the custom provider impls are under crates/maple_core/src/stdio_server, e.g., https://github.com/liuchengxu/vim-clap/blob/master/crates/maple_core/src/stdio_server/provider/files.rs. You can use the log to have a quick start, create a config.toml on your system https://github.com/liuchengxu/vim-clap#config-file, ~\AppData\Roaming\Vim\Vim Clap\config\config.toml for Windows, add the log config:

[log]
log-file = "Valid absolute file path on your System"
max-level = "debug"

@fievel
Copy link
Author

fievel commented Jul 4, 2023

all the files in the project root / working directory are shown and not only the one in the given path.

Okay, I see, you need :Clap files --no-cwd --path src. Feel free to re-open if this is not the answer you are looking for. In addition, looks like I need to update the issue #981 with more details, feel free to ask there so that we have a central place to this breaking change, I'm open to suggestions as well.

Ok that's better with --no-cwd, Clap is listing the expected files, but it's then impossible to open (or preview them) because it does not append the argument of path to the file it tries to open. I think it should list the files with

For now, in my example, if I have something like:

<my dir>/src/mylib/a.cxx
<my dir>/inc/b.cxx

If I :Clap files with cwd == <my dir>: I get listed src/mylib/a.cxx and inc/b.cxx and everything works fine because the cwd is <my dir> so I can preview / open everything in relative.

But now if I :Clap files --no-cwd --path src, I get listed mylib/a.cxx but my cwd (in vim) is still <my dir>, so I cannot open or preview because it tries to open <my dir>/mylib/a.cxx which is non-existent on the disk.

IMHO :Clap files should include the path value in its output for it to work.

@fievel
Copy link
Author

fievel commented Jul 4, 2023

Created #992 as it's a different issue than the original one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants