refactor(command): Remove vimscript

dev
nullchilly 2 years ago
parent f57d6badc1
commit c9edb905d3

@ -2,9 +2,25 @@ local M = {}
local flavours = {"latte", "frappe", "macchiato", "mocha"} local flavours = {"latte", "frappe", "macchiato", "mocha"}
function M.cli_flavour_completion() local command = vim.api.nvim_create_user_command
return vim.tbl_keys(require("catppuccin.utils.data").set_of(flavours))
command("Catppuccin", function(inp)
vim.g.catppuccin_flavour = inp.args
vim.cmd "colorscheme catppuccin"
end, {
nargs = 1,
complete = function()
return flavours
end end
})
command("CatppuccinCompile", function()
require("catppuccin.utils.util").compile()
end, {})
command("CatppuccinClean", function()
require("catppuccin.utils.util").clean()
end, {})
local function load() local function load()
local catppuccin = require("catppuccin") local catppuccin = require("catppuccin")

@ -1,10 +1,7 @@
local g = vim.g local g = vim.g
local util = {} local util = {}
local has_nvim07 = vim.fn.has("nvim-0.7")
function util.highlight(group, color) function util.highlight(group, color)
if has_nvim07 then
if color.link then if color.link then
vim.api.nvim_set_hl(0, group, { vim.api.nvim_set_hl(0, group, {
link = color.link, link = color.link,
@ -19,21 +16,6 @@ function util.highlight(group, color)
color.style = nil color.style = nil
vim.api.nvim_set_hl(0, group, color) vim.api.nvim_set_hl(0, group, color)
end end
else -- Doc: :h highlight-gui
if color.style then
color.style = table.concat(color.style, ",")
end
local style = (color.style and color.style ~= "") and "gui=" .. color.style or "gui=NONE"
local fg = color.fg and "guifg=" .. color.fg or "guifg=NONE"
local bg = color.bg and "guibg=" .. color.bg or "guibg=NONE"
local sp = color.sp and "guisp=" .. color.sp or ""
local blend = color.blend and "blend=" .. color.blend or ""
local hl = "highlight " .. group .. " " .. style .. " " .. fg .. " " .. bg .. " " .. sp .. " " .. blend
vim.cmd(hl)
if color.link then
vim.cmd("highlight! link " .. group .. " " .. color.link)
end
end
end end
function util.syntax(tbl) function util.syntax(tbl)

@ -1,16 +0,0 @@
if exists('g:loaded_catppuccin') | finish | endif
function! s:FlavourCompletion(...) abort
return join(sort(luaeval("require'catppuccin.main'.cli_flavour_completion()")), "\n")
endfunction
function! s:ApplyFlavour(args) abort
let g:catppuccin_flavour = matchstr(a:args[0], "[a-z]*")
colorscheme catppuccin
endfunction
command! -nargs=1 -complete=custom,s:FlavourCompletion Catppuccin call s:ApplyFlavour([<f-args>])
command! CatppuccinCompile lua require("catppuccin.utils.util").compile()
command! CatppuccinClean lua require("catppuccin.utils.util").clean()
let g:loaded_catppuccin = 1
Loading…
Cancel
Save