vim-language-server
vim-language-server copied to clipboard
Feature: goto definition for values defined in another script
First, thanks for this language server! It does its job well.
I have lots of plugins and it would be nice if I could jump to the definition of a function, a variable, or a command that is defined in another function. For example:
:verbose command FiletypeFormat
Name Args Address Complete Definition
FiletypeFormat 0 % silent! let b:filetype_formatter_winview = winsaveview() | <line1>,<line2>call filetype_formatter#format_filetype() | silent call winrestview(b:filetype_formatter_win
view)
Last set from ~/.config/nvim/pack/packager/start/vim-filetype-formatter/plugin/filetype_formatter.vim line 113
The result gives me the file and line where the command (or function if using function) was last defined. Maybe we can use this, or something like it, to locate definitions in other VimScripts?
The above assumes that the user is using Vim to edit their Vimscript.
It can jump to the plugin vim file and works as expected for me.
Try this in your vimrc:
command Hello echo 'hello'
nmap h :Hello<cr>
Put your cursor over the Hello in the nmap. Does it jump to the command definition for you? It doesn't look like goto definition works for Vim "commands" at all for me.
Also, for functions, after some more testing, I've found that the problem seems to be that if a function contains an underscore (_) in its name, goto definition does not work.
filetype_formatter#echo_log() defined in autoload/filetype_formatter is not found.
No, it does not support command, because it can not recognize the 'Hello' as an command in 'nmap h :Hello
I don't know how you test with funcrion but it works well for me. Make sure your files in workspace or vim runtime path.
Should it handle vim9script as well as classic vimscript? With the following init options
\ indexes: {
\ "runtimepath": v:true,
\ "gap": 100,
\ "count": 3,
\ },
\ suggest: {
\ "fromVimruntime": v:true,
\ "fromRuntimepath": v:true,
\ }
\ },
it indexes all of my classic vimscript plugins, but LspAddServer is not indexed.
vim9script is not support yet https://github.com/iamcco/vim-language-server/issues/78