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

Use ctags if ctags_cmd exists for filetype #33

Merged
merged 2 commits into from
Mar 28, 2019

Conversation

smhc
Copy link
Contributor

@smhc smhc commented Mar 28, 2019

No description provided.

Copy link
Owner

@liuchengxu liuchengxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g:vista_ctags_cmd is used for setting options for running ctags or using another executable for some filetype, e.g., hasktags -o - -c for haskell. I believe this is what you are trying to do:

function! s:GetCustomCmd(ft) abort
if exists('g:vista_ctags_cmd') && has_key(g:vista_ctags_cmd, a:ft)
return g:vista_ctags_cmd[a:ft]
endif
return v:null
endfunction
" FIXME support all languages that ctags does
function! s:Cmd(file) abort
let ft = &filetype
let custom_cmd = s:GetCustomCmd(ft)
if custom_cmd isnot v:null
let cmd = printf('%s %s', custom_cmd, a:file)
return cmd
endif

See all the avaliable executives via :echo g:vista#executives if you want to change the defeault executive.

@liuchengxu
Copy link
Owner

Closing as this logic already exists. Thanks any way.

@liuchengxu liuchengxu closed this Mar 28, 2019
@smhc
Copy link
Contributor Author

smhc commented Mar 28, 2019

I think you misunderstood the change.

In my settings I have:

let g:vista_default_executive = 'vim_lsp'
let g:vista_ctags_cmd = {
\ 'xyz': 'ctags --options=/ctags_opt -f - '
}

i.e I want to use vim-lsp as the executive by default. However, for 'xyz' files, there is no LSP available, so I use ctags with a custom command instead.

My change is about being able to open the vista side-bar with the correct executive for each file type (i.e just type :Vista without args).

An alternative solution is to have a filetype to executive map. However I figure if you have a custom ctags command for a particular filetype, you probably want to use the ctags executive.

@liuchengxu liuchengxu reopened this Mar 28, 2019
@liuchengxu
Copy link
Owner

Thanks for the explanation. That makes sense, I love your idea. Could you please add some comment for this case?

@liuchengxu liuchengxu merged commit 3cfabec into liuchengxu:master Mar 28, 2019
@liuchengxu
Copy link
Owner

Merged, thanks!

@smhc
Copy link
Contributor Author

smhc commented Mar 28, 2019

Ok, I've added some comments. It is somewhat of a workaround. From the docs apparently Vista shoudl cycle through each of the executives until it finds one that returns data.

However when I use vim-lsp for an unsupported filetype I just get the error:
"Retrieving symbols is not avaliable"
I use vim-lsp with a 'whitelist' such that it only runs the LSP server for particular filetypes.

Either way - in addition to this change it might be worth a 'filetype to executive' map so that you don't need to configure ctags arguments, or might want ctags to be the default and vim-lsp to be the exception.

@smhc smhc deleted the patch-1 branch March 28, 2019 04:01
@liuchengxu
Copy link
Owner

That warning message is from:

function! vista#executive#vim_lsp#Execute(bang, should_display) abort
if !s:HasAvaliableServers()
return vista#error#("Retrieving symbols is not avaliable")
endif

And it is indeed needless in this situation. I think we can modify the execute function to run without any check.

@liuchengxu
Copy link
Owner

@smhc Can you see if this branch works as you expected?

@smhc
Copy link
Contributor Author

smhc commented Mar 28, 2019

With that branch the error doesn't display any more. However it doesn't automatically cycle through the executives when just using ":Vista" to open the sidebar.

It does cycle through when using ":Vista finder", however it does that with the master branch as well. I can raise a separate issue to track it properly.

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

Successfully merging this pull request may close these issues.

2 participants