From 2936d3b9cdcd29f70076187f526ee142ce96280c Mon Sep 17 00:00:00 2001 From: Tyler Miller Date: Fri, 2 Aug 2024 03:35:12 -0700 Subject: [PATCH] refactor: migrate `plugin/*.vim` -> `plugin/*.lua` Using Lua instead provides a few small benefits in this case (bytecode compilation/caching, `require()` caching, vim command descriptions, LSP, standard file format, etc.), and it shouldn't cause any issues since we already don't support vim. --- CHANGELOG.md | 2 ++ colors/github_dark.vim | 6 +++--- colors/github_dark_colorblind.vim | 6 +++--- colors/github_dark_default.vim | 6 +++--- colors/github_dark_dimmed.vim | 2 +- colors/github_dark_high_contrast.vim | 2 +- colors/github_dark_tritanopia.vim | 2 +- colors/github_light.vim | 6 +++--- colors/github_light_colorblind.vim | 6 +++--- colors/github_light_default.vim | 6 +++--- colors/github_light_high_contrast.vim | 2 +- colors/github_light_tritanopia.vim | 2 +- plugin/github_theme.lua | 9 +++++++++ plugin/github_theme.vim | 7 ------- 14 files changed, 34 insertions(+), 30 deletions(-) create mode 100644 plugin/github_theme.lua delete mode 100644 plugin/github_theme.vim diff --git a/CHANGELOG.md b/CHANGELOG.md index b04a80a1..eb60f927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ The format is based on [Keep a Changelog], and this project adheres to [Semantic ### Changes +- Moved/migrated `plugin/*.vim` -> `plugin/*.lua` + ### Issues Fix - Made `Color()` constructor idempotent (previously, passing a `Color` inst silently caused a bug) diff --git a/colors/github_dark.vim b/colors/github_dark.vim index 931c442c..21981587 100644 --- a/colors/github_dark.vim +++ b/colors/github_dark.vim @@ -1,9 +1,9 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end -require("github-theme.config").set_theme('github_dark') -require("github-theme").load() +require('github-theme.config').set_theme('github_dark') +require('github-theme').load() EOF diff --git a/colors/github_dark_colorblind.vim b/colors/github_dark_colorblind.vim index 7b567bc8..50ec19c6 100644 --- a/colors/github_dark_colorblind.vim +++ b/colors/github_dark_colorblind.vim @@ -1,9 +1,9 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end -require("github-theme.config").set_theme('github_dark_colorblind') -require("github-theme").load() +require('github-theme.config').set_theme('github_dark_colorblind') +require('github-theme').load() EOF diff --git a/colors/github_dark_default.vim b/colors/github_dark_default.vim index 6833f7a7..27c302dc 100644 --- a/colors/github_dark_default.vim +++ b/colors/github_dark_default.vim @@ -1,9 +1,9 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end -require("github-theme.config").set_theme('github_dark_default') -require("github-theme").load() +require('github-theme.config').set_theme('github_dark_default') +require('github-theme').load() EOF diff --git a/colors/github_dark_dimmed.vim b/colors/github_dark_dimmed.vim index 50b85250..b6c7d42b 100644 --- a/colors/github_dark_dimmed.vim +++ b/colors/github_dark_dimmed.vim @@ -1,7 +1,7 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end require('github-theme.config').set_theme('github_dark_dimmed') require('github-theme').load() diff --git a/colors/github_dark_high_contrast.vim b/colors/github_dark_high_contrast.vim index e970c42a..bd1221d1 100644 --- a/colors/github_dark_high_contrast.vim +++ b/colors/github_dark_high_contrast.vim @@ -1,7 +1,7 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end require('github-theme.config').set_theme('github_dark_high_contrast') require('github-theme').load() diff --git a/colors/github_dark_tritanopia.vim b/colors/github_dark_tritanopia.vim index b3787d6b..637589a5 100644 --- a/colors/github_dark_tritanopia.vim +++ b/colors/github_dark_tritanopia.vim @@ -1,7 +1,7 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end require('github-theme.config').set_theme('github_dark_tritanopia') require('github-theme').load() diff --git a/colors/github_light.vim b/colors/github_light.vim index 8ca9bf5a..144e8a2f 100644 --- a/colors/github_light.vim +++ b/colors/github_light.vim @@ -1,9 +1,9 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end -require("github-theme.config").set_theme('github_light') -require("github-theme").load() +require('github-theme.config').set_theme('github_light') +require('github-theme').load() EOF diff --git a/colors/github_light_colorblind.vim b/colors/github_light_colorblind.vim index 7e0e3d5d..2edd1d6d 100644 --- a/colors/github_light_colorblind.vim +++ b/colors/github_light_colorblind.vim @@ -1,9 +1,9 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end -require("github-theme.config").set_theme('github_light_colorblind') -require("github-theme").load() +require('github-theme.config').set_theme('github_light_colorblind') +require('github-theme').load() EOF diff --git a/colors/github_light_default.vim b/colors/github_light_default.vim index 8856f281..658e13fe 100644 --- a/colors/github_light_default.vim +++ b/colors/github_light_default.vim @@ -1,9 +1,9 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end -require("github-theme.config").set_theme('github_light_default') -require("github-theme").load() +require('github-theme.config').set_theme('github_light_default') +require('github-theme').load() EOF diff --git a/colors/github_light_high_contrast.vim b/colors/github_light_high_contrast.vim index 91b9fe19..911961ef 100644 --- a/colors/github_light_high_contrast.vim +++ b/colors/github_light_high_contrast.vim @@ -1,7 +1,7 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end require('github-theme.config').set_theme('github_light_high_contrast') require('github-theme').load() diff --git a/colors/github_light_tritanopia.vim b/colors/github_light_tritanopia.vim index 75c6dd0b..ededae6f 100644 --- a/colors/github_light_tritanopia.vim +++ b/colors/github_light_tritanopia.vim @@ -1,7 +1,7 @@ lua << EOF if vim.g.github_theme_debug then - require("github-theme.util.reload")() + require('github-theme.util.reload')() end require('github-theme.config').set_theme('github_light_tritanopia') require('github-theme').load() diff --git a/plugin/github_theme.lua b/plugin/github_theme.lua new file mode 100644 index 00000000..5d62919d --- /dev/null +++ b/plugin/github_theme.lua @@ -0,0 +1,9 @@ +local api = vim.api + +api.nvim_create_user_command('GithubThemeCompile', function(_info) + require('github-theme').compile(true) +end, { desc = 'Forcefully recompile settings and persist to fs', force = true }) + +api.nvim_create_user_command('GithubThemeInteractive', function(_info) + require('github-theme.interactive').attach() +end, { desc = 'Reload on buffer save', force = true }) diff --git a/plugin/github_theme.vim b/plugin/github_theme.vim deleted file mode 100644 index 06d9875c..00000000 --- a/plugin/github_theme.vim +++ /dev/null @@ -1,7 +0,0 @@ -" Load only once -if exists('g:loaded_github_theme') | finish | endif - -command! GithubThemeCompile lua require('github-theme').compile() -command! GithubThemeInteractive lua require('github-theme.interactive').attach() - -let g:loaded_github_theme = 1