liuchengxu / vista.vim

:cactus: Viewer & Finder for LSP symbols and tags
https://liuchengxu.github.io/vista.vim
MIT License
1.88k stars 89 forks source link

Vista ctags get an empty windows with errors. #386

Closed markwu closed 3 years ago

markwu commented 3 years ago

Describe the bug :Vista ctags get an empty windows with errors.

Environment:

Vista info

    Current FileType:
Avaliable Executives: ['ctags']
    Global Variables:
    let g:vista = {'get_tagline_under_cursor': function('3'), 'winnr': function('1'), 'source': {'fname': '', 'bufnr': 1, 'get_winid': function
('5'), 'winid': 1000, 'winnr': 1, 'extension': function('10'), 'line': function('8'), 'get_winnr': function('4'), 'filetype': function('6'), 'l
ines': function('7'), 'line_trimmed': function('9'), 'scope_seperator': function('11'), 'fpath': ''}, 'provider': 'ctags', 'ctags_cmd': 'ctags
--format=2 --excmd=pattern --fields=nksSaf --extras=+F --sort=no --append=no --extras=   --output-format=json --fields=-PF -f- /var/folders/y2/
qvr3832j08340b8y6sbdv6dm0000gn/T/5bc9d68a7b31b38e37e90d0d212d42903d9b34e9896412489facb671d0fe6de7', 'winid': function('2'), 'tmps': []}
    let g:vista#executive#ctags#support_json_format = 1
    let g:vista#executives = ['ale', 'coc', 'ctags', 'lcn', 'nvim_lsp', 'vim_lsc', 'vim_lsp']
    let g:vista#extensions = ['markdown', 'rst']
    let g:vista#finders = ['clap', 'fzf', 'skim']
    let g:vista_blink = [2, 100]
    let g:vista_close_on_fzf_select = 0
    let g:vista_close_on_jump = 0
    let g:vista_cursor_delay = 400
    let g:vista_default_executive = 'ctags'
    let g:vista_disable_statusline = 0
    let g:vista_echo_cursor = 1
    let g:vista_enable_centering_jump = 1
    let g:vista_executive_for = {}
    let g:vista_find_absolute_nearest_method_or_function = 0
    let g:vista_find_nearest_method_or_function_delay = 300
    let g:vista_fold_toggle_icons = ['▼', '▶']
    let g:vista_fzf_preview = []
    let g:vista_icon_indent = ['└ ', '│ ']
    let g:vista_ignore_kinds = []
    let g:vista_no_mappings = 0
    let g:vista_sidebar_position = 'vertical botright'
    let g:vista_sidebar_width = 30
    let g:vista_stay_on_open = 1
    let g:vista_top_level_blink = [2, 100]
    let g:vista_update_on_text_changed = 0
    let g:vista_update_on_text_changed_delay = 500

Steps to reproduce given the above info

set nocompatible
filetype off

source ~/.vim/bundle/vim-plug/plug.vim
call plug#begin('~/.vim/bundle/')

Plug 'junegunn/vim-plug'
Plug 'liuchengxu/vista.vim'

call plug#end()

syntax on
filetype plugin indent on

**Steps and errors vista

markwu commented 3 years ago

I tried coc, it has the same errors.

vista

liuchengxu commented 3 years ago

Can not reproduce. Use g:vista_log_file(:h g:vista_log_file), and add some debugging statements via vista#Debug(...) to see what's going on,

markwu commented 3 years ago

Here comes the vista.log for Vista ctags

2021-02-16 01:08:36 ["executive::ctags::s:BuildCmd origin_fpath:/Users/markwu/Projects/vim-test/bundle/vista.vim/autoload/vista.vim"]
2021-02-16 01:08:36 ["executive::ctags::s:ApplyExecute calling s:RunAsyncCommon(ctags --format=2 --excmd=pattern --fields=nksSaf --extras=+F --sort=no --append=no --extras=  --language-force=vim --vim-kinds=acfvmn --output-format=json --fields=-PF -f- /var/folders/y2/qvr3832j08340b8y6sbdv6dm0000gn/T/de6754042e7faa0d64c8cd91cf61a78d99c15e632b353d1d652ef2816966ab03.vim)"]
2021-02-16 01:08:36 ["executive::ctags::s:BuildCmd origin_fpath:/Users/markwu/Projects/vim-test/bundle/vista.vim/autoload/vista.vim"]
2021-02-16 01:08:36 ["executive::ctags::s:ApplyExecute calling s:RunAsyncCommon(ctags --format=2 --excmd=pattern --fields=nksSaf --extras=+F --sort=no --append=no --extras=  --language-force=vim --vim-kinds=acfvmn --output-format=json --fields=-PF -f- /var/folders/y2/qvr3832j08340b8y6sbdv6dm0000gn/T/de6754042e7faa0d64c8cd91cf61a78d99c15e632b353d1d652ef2816966ab03.vim)"]
2021-02-16 01:08:36 ["executive::ctags::s:ApplyExtracted s:fpath:/Users/markwu/Projects/vim-test/bundle/vista.vim/autoload/vista.vim, s:reload_only:v:false, s:should_display:v:true"]
2021-02-16 01:08:36 ["[LSPProcess]should_display, processed_data:{'function': [{'lnum': 7, 'text': '', 'signature': '(dir)'}, {'lnum': 18, 'text': '', 'signature': '()'}, {'lnum': 25, 'text': '', 'signature': '(kind)'}, {'lnum': 29, 'text': '', 'signature': '(provider)'}, {'lnum': 38, 'text': '', 'signature': '(provider,AUF)'}, {'lnum': 44, 'text': '', 'signature': '()'}, {'lnum': 65, 'text': '', 'signature': '(Fn,Args)'}, {'lnum': 69, 'text': '', 'signature': '(filetype)'}, {'lnum': 81, 'text': '', 'signature': '()'}, {'lnum': 93, 'text': '', 'signature': '()'}, {'lnum': 110, 'text': '', 'signature': '()'}, {'lnum': 122, 'text': '', 'signature': '(...)'}, {'lnum': 128, 'text': '', 'signature': '(arg)'}, {'lnum': 160, 'text': '', 'signature': '(fst,snd)'}, {'lnum': 192, 'text': '', 'signature': '(bang,...)'}], 'variable': [{'lnum': 5, 'text': ''}, {'lnum': 11, 'text': ''}, {'lnum': 12, 'text': ''}, {'lnum': 13, 'text': ''}, {'lnum': 15, 'text': ''}, {'lnum': 31, 'text': ''}, {'lnum': 34, 'text': ''}, {'lnum': 46, 'text': ''}, {'lnum': 48, 'text': ''}, {'lnum': 120, 'text': ''}, {'lnum': 131, 'text': ''}, {'lnum': 149, 'text': ''}, {'lnum': 200, 'text': ''}, {'lnum': 209, 'text': ''}]}"]
2021-02-16 01:08:36 ["event.BufEnter",2,"/Users/markwu/Projects/vim-test/__vista__"]
2021-02-16 01:08:37 ["executive::ctags::s:ApplyExtracted s:fpath:/Users/markwu/Projects/vim-test/bundle/vista.vim/autoload/vista.vim, s:reload_only:v:false, s:should_display:v:true"]
2021-02-16 01:08:37 ["[LSPProcess]should_display, processed_data:{'function': [{'lnum': 7, 'text': '', 'signature': '(dir)'}, {'lnum': 18, 'text': '', 'signature': '()'}, {'lnum': 25, 'text': '', 'signature': '(kind)'}, {'lnum': 29, 'text': '', 'signature': '(provider)'}, {'lnum': 38, 'text': '', 'signature': '(provider,AUF)'}, {'lnum': 44, 'text': '', 'signature': '()'}, {'lnum': 65, 'text': '', 'signature': '(Fn,Args)'}, {'lnum': 69, 'text': '', 'signature': '(filetype)'}, {'lnum': 81, 'text': '', 'signature': '()'}, {'lnum': 93, 'text': '', 'signature': '()'}, {'lnum': 110, 'text': '', 'signature': '()'}, {'lnum': 122, 'text': '', 'signature': '(...)'}, {'lnum': 128, 'text': '', 'signature': '(arg)'}, {'lnum': 160, 'text': '', 'signature': '(fst,snd)'}, {'lnum': 192, 'text': '', 'signature': '(bang,...)'}], 'variable': [{'lnum': 5, 'text': ''}, {'lnum': 11, 'text': ''}, {'lnum': 12, 'text': ''}, {'lnum': 13, 'text': ''}, {'lnum': 15, 'text': ''}, {'lnum': 31, 'text': ''}, {'lnum': 34, 'text': ''}, {'lnum': 46, 'text': ''}, {'lnum': 48, 'text': ''}, {'lnum': 120, 'text': ''}, {'lnum': 131, 'text': ''}, {'lnum': 149, 'text': ''}, {'lnum': 200, 'text': ''}, {'lnum': 209, 'text': ''}]}"]
markwu commented 3 years ago

I think it might be universal-ctags change something, Vista ctags works about one ago, but failed in recent commit. I can't tell which commit cause this.

I revert to the version about one years ago Universal Ctags 0.0.0(d22e13ef), it works.

markwu commented 3 years ago

Okay, I found it. It seems you didn't use the same universal-ctags version as mine to test, that's why you can not reproduce the bug.

After this commit https://github.com/universal-ctags/ctags/commit/c0421c5ec596b5f2a3e1a16a61d6ee3368a68842 in universal-ctags repository, Vista ctags can't work anymore.

markwu commented 3 years ago

About the failed of Vista coc, I have no idea at this moment.

liuchengxu commented 3 years ago

@masatake The latest commit of u-ctags does not produce the name field anymore using the following command, any insights?

$ ctags --format=2 --excmd=pattern --fields=nksSaf --extras=+F --sort=no --append=no --extras=  --language-force=vim --vim-kinds=acfvmn --output-format=json --fields=-PF -f- autoload/vista.vim
# `name` field is missing
{"_type": "tag", "line": 5, "kind": "variable"}
......
masatake commented 3 years ago

I'm sorry. I changed.

Instead of --fields=nksSaf you should use A. --fields=+nksSaf, or B. --fields=NFPTtnksSaf

This means you should add optional fields you need to field enabled by default (A) or set all fields you need (B).

Both A and B must work with the latest u-ctags and relatively older u-ctags.

liuchengxu commented 3 years ago

Thanks for the info @masatake, anything I can do in vista.vim to detect if the u-ctags is recent enough so that people using the older u-ctags won't complain?

masatake commented 3 years ago

Thanks for the info @masatake, anything I can do in vista.vim to detect if the u-ctags is recent enough so that people using the older u-ctags won't complain?

I don't find a good answer to the question. How about ./configure alike approach?

  1. vista developers list up all fields (field list) needed in vista.vim. You can choose them from ctags --list-fields.
  2. Before vista.vim calls ctags, vista.vim inquiries ctags which fields are available with following command line:
      u-ctags  --quiet --options=NONE --fields='NFPTtnksSaf' --_fatal-warnings /dev/null

    Here NFPTtnksSaf is the field list.

  3. vista.vim checks the exit status. If it is 0, all fields vista.vim needs are available.

In step 2., u-ctags reports which field is not available to stderr.

masatake commented 3 years ago

You can send a pull request that includes test cases that verifies ctags behavior that vista.vim expects. u-ctags developers can know their changes breaking the interface before merging. I cannot promise u-ctags never breaks the interface, but I will notify the change.

liuchengxu commented 3 years ago

Just tested --fields=+nksSaf works with both the latest and the older version.

You can send a pull request that includes test cases that verifies ctags behavior that vista.vim expects.

I'm happy to do that, could you point out where should I add such a test? @masatake

masatake commented 3 years ago

I wrote an example test case for vista.vim. See https://github.com/masatake/ctags/commit/a7fe9f247094b092d838e9247f785d269216a9b6 at my repository. It already works. You can extend the test case and/or add more test cases under Tmai. See the commit log.

This is an interesting challenge for me to make an eco-system. I would like to apply this approach to other client tools. This is the first one. Inputs are welcome.

liuchengxu commented 3 years ago

I'll look into that tomorrow :+1:, and happy to see vista.vim can be the first one of many in the future :(.

markwu commented 3 years ago

I confirm this issue fixed in commit https://github.com/liuchengxu/vista.vim/commit/cdccc4789e1a6f41a2688e58c051a2c00fcccd5f. Should I report Vista coc in another issue? Or I can put it here?

liuchengxu commented 3 years ago

Please file a new issue, looks like the response of coc.nvim's API changed.