mirror of https://github.com/gabehf/base46.git
commit
a633a3f02b
@ -0,0 +1,21 @@
|
||||
nvim-base16.lua is a library for modifying themes with Lua
|
||||
Copyright © 2019 Ashkan Kiani
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
||||
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
@ -0,0 +1,78 @@
|
||||
## base16.lua
|
||||
|
||||
## Usage
|
||||
|
||||
Basic usage:
|
||||
|
||||
```lua
|
||||
lua << EOF
|
||||
local base16 = require 'base16'
|
||||
base16(base16.themes.brewer, true)
|
||||
EOF
|
||||
```
|
||||
|
||||
This is how I use it. Uses [`norcalli/nvim.lua`](https://github.com/norcalli/nvim.lua).
|
||||
|
||||
```lua
|
||||
lua << EOF
|
||||
nvim = require 'nvim'
|
||||
local base16 = require 'base16'
|
||||
base16(base16.themes[nvim.env.BASE16_THEME or "3024"], true)
|
||||
EOF
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### base16.apply_theme(theme_definition: dict, use_256_colorspace: bool)
|
||||
### base16(theme_definition: dict, use_256_colorspace: bool)
|
||||
|
||||
Alias for `base16.apply_theme(theme_definition: dict, use_256_colorspace: bool)`.
|
||||
|
||||
Example:
|
||||
|
||||
```lua
|
||||
base16(base16.themes["brewer"], true)
|
||||
```
|
||||
|
||||
|
||||
### base16.theme_names() -> string
|
||||
|
||||
Return a list of all available theme names. Shortcut for fetching the keys from `base16.themes`.
|
||||
|
||||
Example:
|
||||
|
||||
```lua
|
||||
print(vim.inspect(base16.theme_names()))
|
||||
```
|
||||
|
||||
## Variables
|
||||
|
||||
### base16.themes
|
||||
|
||||
Dictionary of definitions to be used by `base16` or `base16.apply_theme`.
|
||||
|
||||
Example:
|
||||
|
||||
```lua
|
||||
base16.themes["zenburn"] == {
|
||||
base00 = "383838"; base01 = "404040"; base02 = "606060"; base03 = "6f6f6f";
|
||||
base04 = "808080"; base05 = "dcdccc"; base06 = "c0c0c0"; base07 = "ffffff";
|
||||
base08 = "dca3a3"; base09 = "dfaf8f"; base0A = "e0cf9f"; base0B = "5f7f5f";
|
||||
base0C = "93e0e3"; base0D = "7cb8bb"; base0E = "dc8cc3"; base0F = "000000";
|
||||
}
|
||||
```
|
||||
|
||||
## Notes
|
||||
|
||||
Because this includes a copy of [`norcalli/nvim.lua`](https://github.com/norcalli/nvim.lua), you should put
|
||||
this after `norcalli/nvim.lua` in the plugin list because lua module resolution
|
||||
is first-come-first-served, i.e.
|
||||
|
||||
```vim
|
||||
Plug "norcalli/nvim.lua"
|
||||
Plug "norcalli/nvim-base16.lua"
|
||||
```
|
||||
|
||||
## Credits
|
||||
|
||||
Chris Kempson and [Base16](https://github.com/chriskempson/base16) and [base16-vim](https://github.com/chriskempson/base16-vim)
|
||||
@ -0,0 +1,23 @@
|
||||
Base16 Vim is released under the MIT License:
|
||||
|
||||
Copyright (C) 2012 [Chris Kempson](http://chriskempson.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,141 @@
|
||||
-- Equivalent to `echo vim.inspect(...)`
|
||||
local function nvim_print(...)
|
||||
if select("#", ...) == 1 then
|
||||
vim.api.nvim_out_write(vim.inspect((...)))
|
||||
else
|
||||
vim.api.nvim_out_write(vim.inspect {...})
|
||||
end
|
||||
vim.api.nvim_out_write("\n")
|
||||
end
|
||||
|
||||
--- Equivalent to `echo` EX command
|
||||
local function nvim_echo(...)
|
||||
for i = 1, select("#", ...) do
|
||||
local part = select(i, ...)
|
||||
vim.api.nvim_out_write(tostring(part))
|
||||
-- vim.api.nvim_out_write("\n")
|
||||
vim.api.nvim_out_write(" ")
|
||||
end
|
||||
vim.api.nvim_out_write("\n")
|
||||
end
|
||||
|
||||
-- `nvim.$method(...)` redirects to `nvim.api.nvim_$method(...)`
|
||||
-- `nvim.fn.$method(...)` redirects to `vim.api.nvim_call_function($method, {...})`
|
||||
-- TODO `nvim.ex.$command(...)` is approximately `:$command {...}.join(" ")`
|
||||
-- `nvim.print(...)` is approximately `echo vim.inspect(...)`
|
||||
-- `nvim.echo(...)` is approximately `echo table.concat({...}, '\n')`
|
||||
-- Both methods cache the inital lookup in the metatable, but there is a small overhead regardless.
|
||||
return setmetatable({
|
||||
print = nvim_print;
|
||||
echo = nvim_echo;
|
||||
fn = setmetatable({}, {
|
||||
__index = function(self, k)
|
||||
local mt = getmetatable(self)
|
||||
local x = mt[k]
|
||||
if x ~= nil then
|
||||
return x
|
||||
end
|
||||
local f = function(...) return vim.api.nvim_call_function(k, {...}) end
|
||||
mt[k] = f
|
||||
return f
|
||||
end
|
||||
});
|
||||
buf = setmetatable({
|
||||
}, {
|
||||
__index = function(self, k)
|
||||
local mt = getmetatable(self)
|
||||
local x = mt[k]
|
||||
if x ~= nil then
|
||||
return x
|
||||
end
|
||||
local f = function(...)
|
||||
vim.api['nvim_buf_'..k](0, ...)
|
||||
end
|
||||
mt[k] = f
|
||||
return f
|
||||
end
|
||||
});
|
||||
ex = setmetatable({}, {
|
||||
__index = function(self, k)
|
||||
local mt = getmetatable(self)
|
||||
local x = mt[k]
|
||||
if x ~= nil then
|
||||
return x
|
||||
end
|
||||
local command = k:gsub("_$", "!")
|
||||
local f = function(...)
|
||||
return vim.api.nvim_command(table.concat(vim.tbl_flatten {command, ...}, " "))
|
||||
end
|
||||
mt[k] = f
|
||||
return f
|
||||
end
|
||||
});
|
||||
g = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return vim.api.nvim_get_var(k)
|
||||
end;
|
||||
__newindex = function(_, k, v)
|
||||
if v == nil then
|
||||
return vim.api.nvim_del_var(k)
|
||||
else
|
||||
return vim.api.nvim_set_var(k, v)
|
||||
end
|
||||
end;
|
||||
});
|
||||
v = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return vim.api.nvim_get_vvar(k)
|
||||
end;
|
||||
__newindex = function(_, k, v)
|
||||
return vim.api.nvim_set_vvar(k, v)
|
||||
end
|
||||
});
|
||||
b = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return vim.api.nvim_buf_get_var(0, k)
|
||||
end;
|
||||
__newindex = function(_, k, v)
|
||||
if v == nil then
|
||||
return vim.api.nvim_buf_del_var(0, k)
|
||||
else
|
||||
return vim.api.nvim_buf_set_var(0, k, v)
|
||||
end
|
||||
end
|
||||
});
|
||||
o = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return vim.api.nvim_get_option(k)
|
||||
end;
|
||||
__newindex = function(_, k, v)
|
||||
return vim.api.nvim_set_option(k, v)
|
||||
end
|
||||
});
|
||||
bo = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return vim.api.nvim_buf_get_option(0, k)
|
||||
end;
|
||||
__newindex = function(_, k, v)
|
||||
return vim.api.nvim_buf_set_option(0, k, v)
|
||||
end
|
||||
});
|
||||
env = setmetatable({}, {
|
||||
__index = function(_, k)
|
||||
return vim.api.nvim_call_function('getenv', {k})
|
||||
end;
|
||||
__newindex = function(_, k, v)
|
||||
return vim.api.nvim_call_function('setenv', {k, v})
|
||||
end
|
||||
});
|
||||
}, {
|
||||
__index = function(self, k)
|
||||
local mt = getmetatable(self)
|
||||
local x = mt[k]
|
||||
if x ~= nil then
|
||||
return x
|
||||
end
|
||||
local f = vim.api['nvim_'..k]
|
||||
mt[k] = f
|
||||
return f
|
||||
end
|
||||
})
|
||||
|
||||
Loading…
Reference in new issue