vim
vim copied to clipboard
Add 'include' and 'define' patterns for vim9script in ftplugin/vim.vim
The ftplugin for '.vim' files does not seem to have 'include' and 'define' patterns; adding them would enhance navigation across Vimscript files, at least for vim9script, by leveraging the language's "import" feature and Vim's native symbol navigation commands.
Describe the solution you'd like The following settings appear to be working for me, but suggestions and improvements are welcome:
setlocal include=\\v^\\s*import\\s*(autoload)?
setlocal define=\\v^(export)?\\s*def
Thank you for your attention.
I personally use the following here: https://gist.github.com/bfrg/a7343cb63b4a7170a140e9b5b9326b23
The ftplugin for '.vim' files does not seem to have 'include' and 'define' patterns; adding them would enhance navigation across Vimscript files, at least for vim9script, by leveraging the language's "import" feature and Vim's native symbol navigation commands.
Describe the solution you'd like The following settings appear to be working for me, but suggestions and improvements are welcome:
setlocal include=\\v^\\s*import\\s*(autoload)? setlocal define=\\v^(export)?\\s*def
Good idea. There are more things that can be exported, this should cover them:
setlocal define=\\v^\\s*export\\s*(def\|const\|var\|final)
-- "I can't complain, but sometimes I still do." (Joe Walsh)
/// Bram Moolenaar -- @.*** -- http://www.Moolenaar.net \
/// \
\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\ help me help AIDS victims -- http://ICCF-Holland.org ///
I personally use the following here: https://gist.github.com/bfrg/a7343cb63b4a7170a140e9b5b9326b23
Hmm, I don't think ":command" needs to be found with 'define'. You can find commans with [i or jump to them with [<Tab>.
I'm not sure, but finding exported items only with [d seems useful.
-- hundred-and-one symptoms of being an internet addict: 54. You start tilting your head sideways to smile. :-)
/// Bram Moolenaar -- @.*** -- http://www.Moolenaar.net \
/// \
\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\ help me help AIDS victims -- http://ICCF-Holland.org ///
@brammool Should I open a pull request?
@brammool Should I open a pull request?
This is what I have now:
" set 'include' to recognize import commands
setlocal include=\\v^\\s*import\\s*(autoload)?
" set 'define' to recognize export commands
setlocal define=\\v^\\s*export\\s*(def\|const\|var\|final)
Let me know if you prefer something else.
-- Keyboard not found. Think ENTER to continue.
/// Bram Moolenaar -- @.*** -- http://www.Moolenaar.net \
/// \
\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\ help me help AIDS victims -- http://ICCF-Holland.org ///
@brammool I'm ok with your solution. Thank you.
Hmm, I don't think ":command" needs to be found with 'define'. You can find commands with [i or jump to them with [<Tab>.
Yes, you're right.
This is what I have now:
" set 'include' to recognize import commands setlocal include=\v^\simport\s(autoload)?
" set 'define' to recognize export commands setlocal define=\v^\sexport\s(def|const|var|final)
I think making export
optional is helpful so that jumping to a script-local function or variable is possible.
Hmm, I don't think ":command" needs to be found with 'define'. You can find commands with [i or jump to them with [<Tab>.
Yes, you're right.
This is what I have now:
" set 'include' to recognize import commands setlocal include=\v^\simport\s(autoload)?
" set 'define' to recognize export commands setlocal define=\v^\sexport\s(def|const|var|final)
I think making
export
optional is helpful so that jumping to a script-local function or variable is possible.
From inside one script? Then you can use "*" or "gD".
From another script items without "export" are not usable, thus finding them might be confusing. Strictly speaking, if there are two imported scripts, both defining a function Xfunc, but only one exports Xfunc, then the exported one should be found.
-- I got a new desk stapler. It broke on the first desk I tried.
/// Bram Moolenaar -- @.*** -- http://www.Moolenaar.net \
/// \
\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\ help me help AIDS victims -- http://ICCF-Holland.org ///
This was fixed in 5ed1153.