commit 792824bc25378435fb37ba1c58e9ee371bff41ac
parent 61003383880167765e4bab4dfe679d3ef1f481cc
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Sat, 29 Feb 2020 13:32:30 +0100
Some changes
Yeah I know, my commit messages are incredible.
Diffstat:
5 files changed, 70 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
@@ -0,0 +1,44 @@
+# Schemer: a Vim colorscheme generator
+## What?
+This plugin defines a much simpler language for writing colorschemes, and generates a Vim colorscheme file automatically, including all necessary boilerplate.
+
+It consists of:
+* a new filetype, with the extension '.schemer'
+* an autocommand for the filetype, to generate and set the colorscheme automatically whenever a Schemer file is saved. Can be disabled by setting `g:schemer_no_autocmd`.
+* a command, `SchemerGenerate`, to convert a '.schemer' file into a '.vim' colorscheme file
+* two mappings:
+ * `<Plug>SchemerSynstack` to echo the highlight groups of the word under the cursor
+ * `<Plug>SchemerEdit` to open the '.schemer' file for the current colorscheme. Assumes the '.schemer' file is in ~/.vim/colors.
+
+## Why?
+I like making my own colorschemes, I don't like dealing with Vim's syntax.
+When creating colorschemes, I want to be able to write "give the function a foreground color #f4f400, background color #222222. make it italic" instead of "highlight the function in the gui with foreground color #f4f400, in the gui with background color #222222, in cterm with foreground 5, in cterm with background 7, and give it bold attributes in gui and cterm."
+Similarly, I want to write "link tabline, statusline, and incsearch to linenr" instead of "link tabline to linenr, link statusline to linenr, link incsearch to linenr".
+I also want to easily define my own names for colors.
+
+Vim's syntax feels repetitive to me, and I can't always remember the necessary boilerplate, so I made this. A Schemer colorscheme definition is as simple as:
+
+```
+background dark
+palette:
+ text #333333,
+ bg #e4e4e4,
+ comment #f5f5f5.
+
+Normal text, bg
+Comment comment, bg. italic
+link statusline,statuslinenc normal
+```
+
+In my opinion, much more readable and writable than Vimscript.
+
+## Other alternatives
+There are a few alternative colorscheme generators.
+I took a look at [RNB](https://github.com/romainl/vim-rnb), but it didn't feel right for me, for a few reasons.
+It depends on Ruby, and I'd rather not have any dependencies.
+Also, it still feels too detailed, and there's too much writing.
+That sounds like a childish complaint, but I wanted to make writing colorschemes as simple as possible for me.
+Having to specify the details of every color without actually needing that level of control was too much.
+
+However, this is mainly for me.
+It might not make sense for you, and you might prefer the control you get from other colorscheme generators, which is fine.
diff --git a/autoload/schemer.vim b/autoload/schemer.vim
@@ -1,3 +1,8 @@
+if exists('g:loaded_schemer_autoload')
+ finish
+endif
+let g:loaded_schemer_autoload = 1
+
" the 6 value iterations in the xterm color cube "{{{2
let s:valuerange6 = [ 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF ]
@@ -2661,3 +2666,4 @@ function! Schemer#ProcessFile(file) abort
echom "Written to ~/.vim/colors/".(a:file->substitute(".*/", "", "")->substitute('\.schemer', '.vim', ''))
endfunction
+
diff --git a/ftdetect/schemer.vim b/ftdetect/schemer.vim
@@ -1 +1 @@
-autocmd BufRead,BufNewFile *.schemer set filetype=schemer
+autocmd BufRead,BufNewFile *.schemer setfiletype schemer
diff --git a/ftplugin/schemer.vim b/ftplugin/schemer.vim
@@ -1,15 +1,14 @@
-augroup schemer_buffer
- autocmd! * <buffer>
- autocmd BufWritePost <buffer> silent call Schemer#ProcessFile(expand('%:p')) | execute 'colorscheme '.expand('%:p:t:r')
-augroup END
+if !exists('g:schemer_no_autocmd')
+ augroup schemer_buffer
+ autocmd! * <buffer>
+ autocmd BufWritePost <buffer> SchemerGenerate | execute 'colorscheme '.expand('%:p:t:r')
+ augroup END
+endif
-map <buffer> <leader>CH <Plug>Colorizer
-nnoremap <buffer> <leader>CC :ColorClear<CR>
+command! -bar -buffer SchemerGenerate silent call Schemer#ProcessFile(expand('%:p'))
if !exists('b:undo_ftplugin')
let b:undo_ftplugin = ''
end
-let b:undo_ftplugin .= '|setlocal makeprg< '
let b:undo_ftplugin .= '|exe "au! schemer_buffer * <buffer>"'
-let b:undo_ftplugin .= '|mapc <buffer>'
-let b:undo_ftplugin .= '|nmapc <buffer>'
+let b:undo_ftplugin .= '|delcommand SchemerGenerate'
diff --git a/plugin/schemer.vim b/plugin/schemer.vim
@@ -1,3 +1,11 @@
+if exists('g:loaded_schemer') || &cp
+ finish
+endif
+let g:loaded_schemer = 1
+
+let s:cpo_save = &cpo
+set cpo&vim
+
function! s:edit_colors()
execute "split ~/.vim/colors/".g:colors_name.".schemer"
endfunction
@@ -11,3 +19,6 @@ endfunction
nnoremap <Plug>SchemerEdit :call <SID>edit_colors()<CR>
nnoremap <Plug>SchemerSynstack :call <SID>synstack()<CR>
+
+let &cpo = s:cpo_save
+unlet s:cpo_save