From 584690934618a863ea7ef49a4aebfb48e455eab5 Mon Sep 17 00:00:00 2001 From: Oliver Marriott Date: Thu, 4 Nov 2021 11:57:51 +1100 Subject: [PATCH] Reterm all viml -> vimscript --- BUILD.md | 40 +++++++++---------- CREATE.md | 4 +- EXTEND.md | 4 +- FAQ.md | 16 ++++---- doc/lush.txt | 10 ++--- lua/lush/builder.lua | 4 +- lua/lush/transform/lush_to_lua.lua | 4 +- ...lush_to_viml.lua => lush_to_vimscript.lua} | 2 +- ..._viml.lua => vim_compatible_vimscript.lua} | 2 +- spec/build/build_file.lua | 4 +- spec/transform/viml_spec.moon | 18 ++++----- 11 files changed, 54 insertions(+), 54 deletions(-) rename lua/lush/transform/{lush_to_viml.lua => lush_to_vimscript.lua} (93%) rename lua/lush/transform/{vim_compatible_viml.lua => vim_compatible_vimscript.lua} (86%) diff --git a/BUILD.md b/BUILD.md index 98e060a..02cf665 100644 --- a/BUILD.md +++ b/BUILD.md @@ -5,12 +5,12 @@ Lush Build -- lush_build.lua local colorscheme = require("zenbones") run(colorscheme, - lush_to_viml, + lush_to_vimscript, {overwrite, "colors/zenbones.vim"}) ``` - [What is Lush Build](#what-is-lush-build) -- [Exporting a colorscheme to VimL](#exporting-a-colorscheme-to-viml) +- [Exporting a colorscheme to Vim Script](#exporting-a-colorscheme-to-vim-script) - [Exporting a colorscheme to configurable Lua](#exporting-a-colorscheme-to-configurable-lua) - [Converting a Lush colorscheme into an Alacritty colorscheme](#converting-a-lush-colorscheme-into-an-alacritty-colorscheme) - [Branch transform](#branch-transform) @@ -37,9 +37,9 @@ Transforms can take any additional number of arguments after the table. Lush ships with some default transforms, which are automatically injected into the build environment: -- `lush_to_viml`, head, convert parsed spec into viml +- `lush_to_vimscript`, head, convert parsed spec into vimscript - `lush_to_lua`, head, convert parsed spec into lua -- `vim_compatible_viml`, tail, remove vim-incompatible values from highlight rules +- `vim_compatible_vimscript`, tail, remove vim-incompatible values from highlight rules - `prepend`, tail, prepend one or more items to the given table - `append`, tail, append one or more items to the given table - `branch`, tail, pass a value through a pipeline but return the original value @@ -62,15 +62,15 @@ We will discuss the simplest example, where you have a colorscheme with no variations or configuration options and simply want to let non-lush users use your colorscheme. -## Exporting a colorscheme to VimL +## Exporting a colorscheme to Vim Script -To ship our colorscheme as a viml file, we will need to: +To ship our colorscheme as a vimscript file, we will need to: - load our colorscheme. -- convert it to viml. +- convert it to vimscript. - save the output to a file. -We will use the `lush_to_viml` and `overwrite` transforms. +We will use the `lush_to_vimscript` and `overwrite` transforms. Our build file would look something like this: @@ -83,14 +83,14 @@ local colorscheme = require("my.lush.colorscheme") -- any other arguments form the pipeline. run(colorscheme, - -- now we will convert that colorscheme to a list of viml highlight commands - lush_to_viml, + -- now we will convert that colorscheme to a list of vimscript highlight commands + lush_to_vimscript, - -- we can pass the viml through a vim compatible transform if we want. + -- we can pass the vimscript through a vim compatible transform if we want. -- note: this strips blending - -- vim_compatible_viml, + -- vim_compatible_vimscript, - -- the viml commands alone are generally not enough for a colorscheme, we + -- the vimscript commands alone are generally not enough for a colorscheme, we -- will need to append a few housekeeping lines first. -- -- note how we are passing arguments to append by wrapping the transform in a table. @@ -253,7 +253,7 @@ Before running this build file, we should prepare the destination for `patchwrit After running `:LushBuild`, we will have a `lush_apply` function. By default, `lush_apply` will convert your colorscheme (now compiled as a -table) into viml highlight commands and apply them, but you can provide +table) into vimscript highlight commands and apply them, but you can provide optional function hooks to `lush_apply` to alter data along the way. The following hooks are provided: @@ -265,7 +265,7 @@ The following hooks are provided: - `generate_group_fn = function(group) .. end` - Accepts a group and generate *something* that `apply` will understand. - By default this is a `highlight ...` vim command but you could return other - viml, raw lua, different tables, etc. + vimscript, raw lua, different tables, etc. - The results of this function is collected into a table of "rules", one per group. - `before_apply_fn = function(rules) ... end` @@ -371,12 +371,12 @@ The branch transform allows you to split a pipeline into independant streams. ```lua run(zenbones, - lush_to_viml, + lush_to_vimscript, {branch, - vim_compatible_viml, + vim_compatible_vimscript, {prepend, [["vim-compatible, see http://... for more details]]}, {patchwrite, "../dist/...", [[" M_OPEN]], [[" M_CLOSE]]}}, - -- though vim_compatible_viml has altered the highlight rules, the original + -- though vim_compatible_vimscript has altered the highlight rules, the original -- unmodified rules are passed to the rest of the pipeline. {branch, {patchwrite, "colors/", [[" M_OPEN]], [[" M_CLOSE]]}}) @@ -423,7 +423,7 @@ Every transform accepts and returns a table, this is implied in the documentation, so "returns commands" means "returns a list of strings, where each string is a command". -**`lusn_to_viml`** +**`lusn_to_vimscript`** - Converts a parsed lush spec into highlight commands. - Accepts @@ -435,7 +435,7 @@ each string is a command". - Accepts - none -**`vim_compatible_viml`** +**`vim_compatible_vimscript`** - Removes vim-incompatible attributes from highlight commands - Accepts diff --git a/CREATE.md b/CREATE.md index 83cd558..d3b97c9 100644 --- a/CREATE.md +++ b/CREATE.md @@ -140,7 +140,7 @@ use '~/projects/cool_name' Afterwards we can apply the colorscheme like any other: -```viml +```vimscript colorscheme cool_name ``` @@ -150,7 +150,7 @@ Lush provides a highly extensible export system, called [LushBuild](lush_build.md). It provides some built in tools to export your colorscheme to: -- VimL (for use with Vim, or Neovim) +- Vim Script (for use with Vim, or Neovim) - Lua, with extension hooks to provide end-user configuration - Various terminal emulators diff --git a/EXTEND.md b/EXTEND.md index 66a1658..edb974f 100644 --- a/EXTEND.md +++ b/EXTEND.md @@ -77,7 +77,7 @@ _G.customise_colorscheme = function() end ``` -```viml +```vimscript autocmd VimEnter,ColorScheme * lua customise_colorscheme() ``` @@ -118,7 +118,7 @@ _G.customise_colorscheme = function() end ``` -```viml +```vimscript autocmd VimEnter,ColorScheme * lua customise_colorscheme() ``` diff --git a/FAQ.md b/FAQ.md index 62d31bd..d026053 100644 --- a/FAQ.md +++ b/FAQ.md @@ -99,24 +99,24 @@ Short answer: no. Long answer: -There isn't a noticeable performance impact in using Lush over a raw VimL +There isn't a noticeable performance impact in using Lush over a raw Vim Script colorscheme. The parse and compile stage is generally around 1ms on a quite aged core i5 and is comparatively dwarfed by the 3ms spent waiting Vim's -interpreter to apply the commands, a penalty which raw VimL schemes would +interpreter to apply the commands, a penalty which raw Vim Script schemes would share. If you noticed a poor performance, you can always export your theme to -VimL after using Lush to aid the development process. +Vim Script after using Lush to aid the development process. *Times measured with libuv's hrtime(), specifically around the parse, compile and apply calls. There may be a few extra nanoseconds not recorded between calling in and out of functions, as well as the initial file load time -(which VimL would also incur).* +(which Vim Script would also incur).* ``` Parse: 286300 ns 0.2863 ms -- resolve lush-spec into concrete values -Compile: 671900 ns 0.6719 ms -- convert concrete spec into viml commands -Apply: 3134300 ns 3.1343 ms -- pass to VimL interpreter (iterate array and call "nvim_command", "nvim_exec" performance is identical) +Compile: 671900 ns 0.6719 ms -- convert concrete spec into vimscript commands +Apply: 3134300 ns 3.1343 ms -- pass to Vim Script interpreter (iterate array and call "nvim_command", "nvim_exec" performance is identical) Total: 4092500 ns 4.0925 ms Parse: 373500 ns 0.3735 ms @@ -136,7 +136,7 @@ Total: 4179300 ns 4.1793 ms ``` See also [issue #19](https://github.com/rktjmp/lush.nvim/issues/19), where -1000, 2000 and 4000 rule specs were tested. VimL is stll consistently the +1000, 2000 and 4000 rule specs were tested. Vim Script is stll consistently the bottleneck. Note that a 1000 rule spec is likely pretty unsual. There are only about 150 @@ -146,7 +146,7 @@ less). A 4k rule spec would probably mean you're loading an enourmous number of plugins, at which point your load times are probably also already enormous. -Also as per the issue, since VimL is such a huge bottleneck, you may find +Also as per the issue, since Vim Script is such a huge bottleneck, you may find similarly sized colorschemes actually load *faster* via Lush because any maths and manipulation is done via Lua instead. diff --git a/doc/lush.txt b/doc/lush.txt index 0ac1238..80f142b 100644 --- a/doc/lush.txt +++ b/doc/lush.txt @@ -16,8 +16,8 @@ Lush is a color scheme creation aid, written in Lua, for Neovim. Lush lets you define your scheme as a mini-dsl, provides HSL colour manipulation aids, and gives you real time feedback of your changes. -Lush colorschemes can be exported to plain VimL for distribution (or escape), -and they can also be imported to other Lua (or VimL) files to access color) +Lush colorschemes can be exported to plain Vim Script for distribution (or escape), +and they can also be imported to other Lua (or Vim Script) files to access color) data. ================================================================================ @@ -264,7 +264,7 @@ Here's a very simple lush-spec: And the corresponding colorscheme loading file for nvim: > " cool_name/colors/cool_name.vim - " yes, unfortunately you still have to write some VimL + " yes, unfortunately you still have to write some Vim Script set background=dark let g:colors_name="cool_name" " you could detect background == dark || light here and require @@ -608,7 +608,7 @@ lush spec. See `lush/compiler/plugin/` for implementation details. Lush ships with the following plugins: -- lush_core: always included, base viml generator +- lush_core: always included, base vimscript generator > local compiled = lush.compile(parsed, {plugins = { require("my_compiler_plugin") @@ -679,7 +679,7 @@ Live Search-Replace: Lightline While Lightline can be styled through Lush, real-time updating has some - caveats and performance may be less than optimal due to VimL performance. + caveats and performance may be less than optimal due to Vim Script performance. See `examples/lightline-one-file` and `examples/lightline-two-files` for guidance. Generally, if real time performance with Lightline is problematic, diff --git a/lua/lush/builder.lua b/lua/lush/builder.lua index bdcd838..9c83018 100644 --- a/lua/lush/builder.lua +++ b/lua/lush/builder.lua @@ -52,9 +52,9 @@ local function make_env() local env = { lush = require("lush"), run = require("lush.builder").run, - lush_to_viml = require("lush.transform.lush_to_viml"), + lush_to_vimscript = require("lush.transform.lush_to_vimscript"), lush_to_lua = require("lush.transform.lush_to_lua"), - vim_compatible_viml = require("lush.transform.vim_compatible_viml"), + vim_compatible_vimscript = require("lush.transform.vim_compatible_vimscript"), branch = require("lush.transform.branch"), overwrite = require("lush.transform.overwrite"), patchwrite = require("lush.transform.patchwrite"), diff --git a/lua/lush/transform/lush_to_lua.lua b/lua/lush/transform/lush_to_lua.lua index ab7f009..99d1a20 100644 --- a/lua/lush/transform/lush_to_lua.lua +++ b/lua/lush/transform/lush_to_lua.lua @@ -46,7 +46,7 @@ local lush_apply = function(groups, opts) -- group.data (table of fg, bg, gui, sp and blend)). Should return something -- which apply() knows how to handle. -- - -- By default we generate a viml highlight rule. + -- By default we generate a vimscript highlight rule. local generate_group = options.generate_group_fn or function(group) if group.type == "link" then @@ -80,7 +80,7 @@ local lush_apply = function(groups, opts) -- Accepts a list of each group's result from generate_group_fn. Should -- return something apply_fn can understand. -- - -- By default, generate_group_fn returns a viml "highlight ..." command and + -- By default, generate_group_fn returns a vimscript "highlight ..." command and -- apply_fn assumes it's recieving a list of commands to pass to vim.cmd, but -- you could for example, return a table of functions here and the apply_fn -- could call those functions. diff --git a/lua/lush/transform/lush_to_viml.lua b/lua/lush/transform/lush_to_vimscript.lua similarity index 93% rename from lua/lush/transform/lush_to_viml.lua rename to lua/lush/transform/lush_to_vimscript.lua index 5bc3003..0cf2eaa 100644 --- a/lua/lush/transform/lush_to_viml.lua +++ b/lua/lush/transform/lush_to_vimscript.lua @@ -19,7 +19,7 @@ end return function(ast, config) assert(is_spec(ast), - "first argument to viml transform must be a parsed lush spec") + "first argument to vimscript transform must be a parsed lush spec") local rules = compiler(ast, config) diff --git a/lua/lush/transform/vim_compatible_viml.lua b/lua/lush/transform/vim_compatible_vimscript.lua similarity index 86% rename from lua/lush/transform/vim_compatible_viml.lua rename to lua/lush/transform/vim_compatible_vimscript.lua index af6320e..e0e97ef 100644 --- a/lua/lush/transform/vim_compatible_viml.lua +++ b/lua/lush/transform/vim_compatible_vimscript.lua @@ -1,4 +1,4 @@ ---- Alters a list of viml highlight commands to be vim compatible +--- Alters a list of vim script highlight commands to be vim compatible return function(rules) local collect = {} for _, rule in ipairs(rules) do diff --git a/spec/build/build_file.lua b/spec/build/build_file.lua index bda5731..637a625 100644 --- a/spec/build/build_file.lua +++ b/spec/build/build_file.lua @@ -4,8 +4,8 @@ assert(type(run) == "function") assert(type(branch) == "function") assert(type(overwrite) == "function") assert(type(patchwrite) == "function") -assert(type(lush_to_viml) == "function") -assert(type(vim_compatible_viml) == "function") +assert(type(lush_to_vimscript) == "function") +assert(type(vim_compatible_vimscript) == "function") assert(type(lush_to_lua) == "function") assert(type(prepend) == "function") assert(type(append) == "function") diff --git a/spec/transform/viml_spec.moon b/spec/transform/viml_spec.moon index 6c547f7..a6c59f8 100644 --- a/spec/transform/viml_spec.moon +++ b/spec/transform/viml_spec.moon @@ -1,4 +1,4 @@ -describe "run.viml", -> +describe "run.vimscript", -> run = require("lush.builder").run setup -> @@ -17,14 +17,14 @@ describe "run.viml", -> teardown -> package.loaded["theme"] = nil - it "returns viml", -> - viml = require("lush.transform.lush_to_viml") - value = run(require("theme"), viml) + it "returns vimscript", -> + vimscript = require("lush.transform.lush_to_vimscript") + value = run(require("theme"), vimscript) assert.is.table(value) assert.matches("highlight A guifg=NONE guibg=NONE guisp=NONE gui=italic blend=40", value[1]) - it "orders the viml", -> - viml = require("lush.transform.lush_to_viml") + it "orders the vimscript", -> + vimscript = require("lush.transform.lush_to_vimscript") parse = require('lush.parser') ast = parse -> { Apple { gui: "italic", blend: 40 }, -- first @@ -32,14 +32,14 @@ describe "run.viml", -> Cat { Apple } -- link, so after apple, after bandana Bandana { Apple } -- link, so after apple } - value = run(ast, viml) + value = run(ast, vimscript) assert.match("highlight Apple", value[1]) assert.match("link Bandana Apple", value[2]) assert.match("link Cat Apple", value[3]) assert.match("highlight Bananna", value[4]) -- it "accepts options", -> - -- viml = require("lush.transform.viml") - -- value = run(require("theme"), {viml, {plugins: require("lush.compiler.plugin.vim_compatible")}}) + -- vimscript = require("lush.transform.vimscript") + -- value = run(require("theme"), {vimscript, {plugins: require("lush.compiler.plugin.vim_compatible")}}) -- assert.is.table(value) -- assert.matches("highlight A guifg=NONE guibg=NONE guisp=NONE gui=italic blend=40", value[1])