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

Feature: goto definition for values defined in another script #39

Open
pappasam opened this issue May 5, 2020 · 6 comments
Open

Feature: goto definition for values defined in another script #39

pappasam opened this issue May 5, 2020 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@pappasam
Copy link

pappasam commented May 5, 2020

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.

@iamcco
Copy link
Owner

iamcco commented May 6, 2020

It can jump to the plugin vim file and works as expected for me.

@pappasam
Copy link
Author

pappasam commented May 6, 2020

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.

@iamcco
Copy link
Owner

iamcco commented May 6, 2020

No, it does not support command, because it can not recognize the 'Hello' as an command in 'nmap h :Hello'

@iamcco iamcco added enhancement New feature or request help wanted Extra attention is needed labels May 6, 2020
@iamcco
Copy link
Owner

iamcco commented May 6, 2020

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.

@BourgeoisBear
Copy link

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.

@iamcco
Copy link
Owner

iamcco commented Sep 7, 2023

vim9script is not support yet #78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants