Sublime Forum

Lua: Goto variable declaration

#1

I’m using Lua scripts.
F12 goes only to function declarations.
However, I constantly need to go to variable declarations: local myvar or only myvar.
How to do that?

0 Likes

#2

It would require LUA.sublime-syntax to scope declarations so those could be added to (indexed) symbols.

0 Likes

#3

I did not understand. Could you explain to me how to do this?

0 Likes

#4

All features such as Goto Definition depend on syntax definitions providing proper/required information. Those are missing in the currently quite simple implementation of builtin LUA syntax. Thus syntax definition would need to be extended to provide such information.

The principle behind everything is:

  1. syntax definitions apply scopes to tokens
  2. those scopes can be used to define symbol lists
  3. symbol lists define targets for Goto Definition

In short, Sublime Text doesn’t know about what a variable declaration is, atm. Therefore it would need to be teached about them first.

I am not a LUA expert, but if all declarations looked like local myvar using keyword to initiate declaration, it might probably be not too difficult.

1 Like

#5

Maybe, LSP and LSP-lua can handle it, too.

1 Like

#6

I installed LSP and LSP-lua, it’s helping a lot!
Thank you very much!

0 Likes