From 687eb0b39f3bcad9566198b4c60bbd2755032991 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Mon, 31 May 2021 17:35:13 +0600 Subject: feat(startup): Source runtime/plugin/**/*.lua at startup For opt plugins these files are sourced on `:packadd` * `:runtime` Now can exexute lua files --- runtime/doc/repeat.txt | 8 ++++++-- runtime/doc/starting.txt | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index dd05084652..c7806398d8 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -187,8 +187,10 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. *:ru* *:runtime* :ru[ntime][!] [where] {file} .. - Read Ex commands from {file} in each directory given - by 'runtimepath' and/or 'packpath'. There is no error + Source vim/lua {file} in each directory given by + 'runtimepath' and/or 'packpath'. The vim files are + executed in same mannar as |:source| and lua files + similarly as |:luafile|. There is no error for non-existing files. Example: > @@ -244,6 +246,8 @@ For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. Note that {name} is the directory name, not the name of the .vim file. All the files matching the pattern pack/*/opt/{name}/plugin/**/*.vim ~ + and + pack/*/opt/{name}/plugin/**/*.lua ~ will be sourced. This allows for using subdirectories below "plugin", just like with plugins in 'runtimepath'. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index ae9022c56c..3a3caea126 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -469,10 +469,15 @@ accordingly. Vim proceeds in this order: 7. Load the plugin scripts. *load-plugins* This does the same as the command: > :runtime! plugin/**/*.vim + :runtime! plugin/**/*.lua < The result is that all directories in the 'runtimepath' option will be searched for the "plugin" sub-directory and all files ending in ".vim" - will be sourced (in alphabetical order per directory), also in - subdirectories. + and ".lua" will be sourced (in alphabetical order per directory), + also in subdirectories. First all the "*.vim" files will be sourced and + then all the "*.lua" files will be sourced. If two files with same + name but different extensions exists they will be treated in same + manner. For example when both "foo.vim" and "foo.lua" exists then + first "foo.vim" will be sourced then "foo.lua" will be ran. However, directories in 'runtimepath' ending in "after" are skipped here and only loaded after packages, see below. Loading plugins won't be done when: -- cgit From 1e6c02510afd79659519f2a69075b36784134322 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Wed, 2 Jun 2021 09:32:37 +0600 Subject: feat(runtime): Allow lua to be used in colorschemes * tests(runtime): move runtime/plugin tests to functional/lua/runtime_spec --- runtime/doc/syntax.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/doc') diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index b159f655fa..bf649b5940 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -4749,8 +4749,9 @@ in their own color. feature it will output "unknown". :colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath' - for the file "colors/{name}.vim". The first one that + for the file "colors/{name}.(vim|lua)". The first one that is found is loaded. + Note: "colors/{name}.vim" is tried first. Also searches all plugins in 'packpath', first below "start" and then under "opt". -- cgit From 68be8b99cfb1ab6105c48707986ce409ca38dd35 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Wed, 2 Jun 2021 13:48:13 +0600 Subject: feat(runtime): Allow lua to be used in compiler --- runtime/doc/quickfix.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index a937cfee98..ebc7e2a1b4 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1208,8 +1208,8 @@ not "b:current_compiler". What the command actually does is the following: - Delete the "current_compiler" and "b:current_compiler" variables. - Define the "CompilerSet" user command. With "!" it does ":set", without "!" it does ":setlocal". -- Execute ":runtime! compiler/{name}.vim". The plugins are expected to set - options with "CompilerSet" and set the "current_compiler" variable to the +- Execute ":runtime! compiler/{name}.(vim|lua)". The plugins are expected to + set options with "CompilerSet" and set the "current_compiler" variable to the name of the compiler. - Delete the "CompilerSet" user command. - Set "b:current_compiler" to the value of "current_compiler". -- cgit From fd5e5d2715d264447d94d7253f3c78bd7003a472 Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Wed, 2 Jun 2021 16:25:50 +0600 Subject: feat(runtime): Allow lua to be used in ftplugin --- runtime/doc/usr_05.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc') diff --git a/runtime/doc/usr_05.txt b/runtime/doc/usr_05.txt index d8634ac6ed..d0206ba82d 100644 --- a/runtime/doc/usr_05.txt +++ b/runtime/doc/usr_05.txt @@ -411,7 +411,7 @@ Examples for the "stuff" filetype on Unix: > The part is the name of the filetype the plugin is to be used for. Only files of this filetype will use the settings from the plugin. The part of the plugin file doesn't matter, you can use it to have several plugins -for the same filetype. Note that it must end in ".vim". +for the same filetype. Note that it must end in ".vim" or ".lua". Further reading: -- cgit From e1edc079dd0d0cb4a53e5998086568cf9d10a26a Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Thu, 3 Jun 2021 07:07:51 +0600 Subject: refactor(source): Move lua file detection to do_source So now :source can run lua files too :) * feat: Add support for :[ranged]source for lua files --- runtime/doc/repeat.txt | 6 ++++-- runtime/doc/starting.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime/doc') diff --git a/runtime/doc/repeat.txt b/runtime/doc/repeat.txt index c7806398d8..6755747dcf 100644 --- a/runtime/doc/repeat.txt +++ b/runtime/doc/repeat.txt @@ -172,9 +172,11 @@ Using Vim scripts *using-scripts* For writing a Vim script, see chapter 41 of the user manual |usr_41.txt|. *:so* *:source* *load-vim-script* -:so[urce] {file} Read Ex commands from {file}. These are commands that - start with a ":". +:so[urce] {file} Runs vim or lua {file} Triggers the |SourcePre| autocommand. + + Note: Only files ending with `.lua` is sourced as + lua file. Anything else is assumed to be vimscript. *:source!* :so[urce]! {file} Read Vim commands from {file}. These are commands that are executed from Normal mode, like you type diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 3a3caea126..2110b88330 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -477,7 +477,7 @@ accordingly. Vim proceeds in this order: then all the "*.lua" files will be sourced. If two files with same name but different extensions exists they will be treated in same manner. For example when both "foo.vim" and "foo.lua" exists then - first "foo.vim" will be sourced then "foo.lua" will be ran. + first "foo.vim" will be sourced then "foo.lua" will be sourced. However, directories in 'runtimepath' ending in "after" are skipped here and only loaded after packages, see below. Loading plugins won't be done when: -- cgit