Update generated nvim config
This commit is contained in:
@ -262,17 +262,6 @@ require("lazy").setup({
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"colorizer",
|
||||
["config"] = function(_, opts)
|
||||
require("colorizer").setup(opts)
|
||||
end,
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-colorizer.lua",
|
||||
["enabled"] = false,
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "colorizer",
|
||||
},
|
||||
{
|
||||
"comment",
|
||||
["config"] = function(_, opts)
|
||||
@ -344,7 +333,8 @@ require("lazy").setup({
|
||||
require("flash").setup(opts)
|
||||
end,
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/flash.nvim",
|
||||
["lazy"] = false,
|
||||
["keys"] = { "s", "S", "f", "F", "t", "T" },
|
||||
["lazy"] = true,
|
||||
["name"] = "flash",
|
||||
},
|
||||
{
|
||||
@ -468,6 +458,9 @@ require("lazy").setup({
|
||||
"lspconfig",
|
||||
["cmd"] = { "LspInfo" },
|
||||
["config"] = function(_, opts)
|
||||
-- Make LspInfo window border rounded
|
||||
require("lspconfig.ui.windows").default_options.border = "rounded"
|
||||
|
||||
local __lspOnAttach = function(client, bufnr) end
|
||||
|
||||
local __lspCapabilities = function()
|
||||
@ -539,19 +532,13 @@ require("lazy").setup({
|
||||
end,
|
||||
["dependencies"] = {
|
||||
{
|
||||
"neodev",
|
||||
"lazydev",
|
||||
["config"] = function(_, opts)
|
||||
require("neodev").setup(opts)
|
||||
require("lazydev").setup(opts)
|
||||
end,
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/neodev.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "neodev",
|
||||
["opts"] = {
|
||||
["library"] = { ["enabled"] = true, ["plugins"] = true, ["runtime"] = true, ["types"] = true },
|
||||
["lspconfig"] = true,
|
||||
["pathStrict"] = true,
|
||||
["setup_jsonls"] = false,
|
||||
},
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/vimplugin-nvim-lazydev",
|
||||
["ft"] = { "lua" },
|
||||
["name"] = "lazydev",
|
||||
},
|
||||
},
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-lspconfig",
|
||||
@ -610,21 +597,46 @@ require("lazy").setup({
|
||||
local actions = require("nvim-navbuddy.actions") -- ?
|
||||
require("nvim-navbuddy").setup(opts)
|
||||
end,
|
||||
["dependencies"] = {
|
||||
{
|
||||
"navic",
|
||||
["config"] = function(_, opts)
|
||||
navic = require("nvim-navic")
|
||||
navic.setup(opts)
|
||||
|
||||
-- Register navic with lualine's winbar (NOTE: using incline currently)
|
||||
-- TODO: The setup function should probably only be ran once
|
||||
-- require("lualine").setup({
|
||||
-- winbar = {
|
||||
-- lualine_c = {
|
||||
-- {
|
||||
-- function()
|
||||
-- return navic.get_location()
|
||||
-- end,
|
||||
-- cond = function()
|
||||
-- return navic.is_available()
|
||||
-- end
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
-- })
|
||||
end,
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-navic",
|
||||
["lazy"] = true,
|
||||
["name"] = "navic",
|
||||
["opts"] = {
|
||||
["click"] = true,
|
||||
["depth_limit"] = 5,
|
||||
["highlight"] = true,
|
||||
["lsp"] = { ["auto_attach"] = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-navbuddy",
|
||||
["lazy"] = true,
|
||||
["name"] = "navbuddy",
|
||||
["opts"] = { ["lsp"] = { ["auto_attach"] = true }, ["window"] = { ["border"] = "rounded" } },
|
||||
},
|
||||
{
|
||||
"navic",
|
||||
["config"] = function(_, opts)
|
||||
require("nvim-navic").setup(opts)
|
||||
end,
|
||||
["dir"] = "/home/lab/smchurla/Downloads/flake-nixinator/config/neovim/store/lazy-plugins/nvim-navic",
|
||||
["lazy"] = false,
|
||||
["name"] = "navic",
|
||||
["opts"] = { ["click"] = true, ["highlight"] = true, ["lsp"] = { ["auto_attach"] = true } },
|
||||
},
|
||||
{
|
||||
"neo-tree",
|
||||
["cmd"] = { "Neotree" },
|
||||
@ -1028,13 +1040,18 @@ do
|
||||
{ ["action"] = ":m '<-2<cr>gv=gv", ["key"] = "<M-k>", ["mode"] = "v", ["options"] = {
|
||||
["desc"] = "Move line up",
|
||||
} },
|
||||
{ ["action"] = "<cmd>w<cr>", ["key"] = "<C-s>", ["mode"] = "n", ["options"] = {
|
||||
["desc"] = "Save current buffer",
|
||||
} },
|
||||
{ ["action"] = "<cmd>wa<cr>", ["key"] = "<C-S-s>", ["mode"] = "n", ["options"] = {
|
||||
["desc"] = "Save all buffers",
|
||||
} },
|
||||
{ ["action"] = "<Esc>", ["key"] = ";", ["mode"] = "v", ["options"] = { ["desc"] = "Exit visual mode" } },
|
||||
{
|
||||
["action"] = "<cmd>w<cr>",
|
||||
["key"] = "<C-s>",
|
||||
["mode"] = { "n", "i", "v" },
|
||||
["options"] = { ["desc"] = "Save current buffer" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>wa<cr>",
|
||||
["key"] = "<C-S-s>",
|
||||
["mode"] = { "n", "i", "v" },
|
||||
["options"] = { ["desc"] = "Save all buffers" },
|
||||
},
|
||||
{ ["action"] = "<gv", ["key"] = "<", ["mode"] = "v", ["options"] = { ["desc"] = "Outdent" } },
|
||||
{ ["action"] = "v<<Esc>", ["key"] = "<", ["mode"] = "n", ["options"] = { ["desc"] = "Outdent" } },
|
||||
{ ["action"] = ">gv", ["key"] = ">", ["mode"] = "v", ["options"] = { ["desc"] = "Indent" } },
|
||||
@ -1061,6 +1078,18 @@ do
|
||||
["desc"] = "Paste from clipboard",
|
||||
} },
|
||||
{ ["action"] = '"+y', ["key"] = "<C-S-c>", ["mode"] = "v", ["options"] = { ["desc"] = "Copy to clipboard" } },
|
||||
{
|
||||
["action"] = "<cmd>lua require('flash').jump()<cr>",
|
||||
["key"] = "s",
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Flash jump" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>lua require('flash').treesitter()<cr>",
|
||||
["key"] = "S",
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Flash treesitter" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>nohlsearch<cr>",
|
||||
["key"] = "<C-h>",
|
||||
@ -1079,6 +1108,7 @@ do
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Find in current buffer" },
|
||||
},
|
||||
{ ["action"] = "<Esc>", ["key"] = ";", ["mode"] = "v", ["options"] = { ["desc"] = "Exit visual mode" } },
|
||||
{ ["action"] = "<cmd>Lazy<cr>", ["key"] = "<leader>L", ["mode"] = "n", ["options"] = { ["desc"] = "Show Lazy" } },
|
||||
{
|
||||
["action"] = "<cmd>w<cr>",
|
||||
@ -1265,6 +1295,12 @@ do
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Toggle autoformat-on-save" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>ToggleAutoLint<cr>",
|
||||
["key"] = "<leader>tl",
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Toggle autolint-on-save" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>ToggleInlineDiagnostics<cr>",
|
||||
["key"] = "<leader>tD",
|
||||
@ -1397,6 +1433,9 @@ end
|
||||
|
||||
vim.filetype.add({ ["extension"] = { ["v"] = "vlang" } })
|
||||
|
||||
-- Make Lazy window border rounded
|
||||
require("lazy.core.config").options.ui.border = "rounded"
|
||||
|
||||
-- Toggle inline diagnostics and show border
|
||||
vim.g.enable_inline_diagnostics = false
|
||||
vim.diagnostic.config({
|
||||
@ -1434,12 +1473,27 @@ end, {
|
||||
desc = "Print LSP server configuration",
|
||||
})
|
||||
|
||||
-- Toggle linting
|
||||
vim.g.disable_autolint = false
|
||||
vim.api.nvim_create_user_command("ToggleAutoLint", function()
|
||||
vim.g.disable_autolint = not vim.g.disable_autolint
|
||||
if vim.g.disable_autolint then
|
||||
-- vim.diagnostic.reset(vim.api.nvim_get_current_buf())
|
||||
vim.diagnostic.reset() -- Reset for all buffers
|
||||
end
|
||||
require("notify")((vim.g.disable_autolint and "Disabled" or "Enabled") .. " autolint-on-save")
|
||||
end, {
|
||||
desc = "Toggle autolint-on-save",
|
||||
})
|
||||
|
||||
-- Set up autocommands {{
|
||||
do
|
||||
local __nixvim_autocommands = {
|
||||
{
|
||||
["callback"] = function()
|
||||
if not vim.g.disable_autolint then
|
||||
require("lint").try_lint()
|
||||
end
|
||||
end,
|
||||
["event"] = { "BufWritePost" },
|
||||
},
|
||||
|
||||
@ -72,7 +72,7 @@ vim.cmd([[
|
||||
]])
|
||||
require("lazy").setup({
|
||||
dev = {
|
||||
path = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins",
|
||||
path = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins",
|
||||
patterns = { "." },
|
||||
fallback = false,
|
||||
},
|
||||
@ -87,7 +87,7 @@ require("lazy").setup({
|
||||
colorscheme catppuccin
|
||||
]])
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/catppuccin-nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/catppuccin-nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "catppuccin",
|
||||
["opts"] = { ["background"] = { ["dark"] = "mocha", ["light"] = "latte" }, ["flavour"] = "mocha" },
|
||||
@ -98,7 +98,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("nvim-web-devicons").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-web-devicons",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-web-devicons",
|
||||
["lazy"] = true,
|
||||
["name"] = "web-devicons",
|
||||
},
|
||||
@ -107,7 +107,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("nvim-autopairs").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-autopairs",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-autopairs",
|
||||
["event"] = { "InsertEnter" },
|
||||
["lazy"] = true,
|
||||
["name"] = "autopairs",
|
||||
@ -116,7 +116,7 @@ require("lazy").setup({
|
||||
{
|
||||
"bbye",
|
||||
["cmd"] = { "Bdelete", "Bwipeout" },
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/vim-bbye",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/vim-bbye",
|
||||
["lazy"] = true,
|
||||
["name"] = "bbye",
|
||||
},
|
||||
@ -125,7 +125,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("better_escape").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/better-escape.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/better-escape.nvim",
|
||||
["event"] = { "InsertEnter" },
|
||||
["lazy"] = true,
|
||||
["name"] = "better-escape",
|
||||
@ -136,7 +136,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("clangd_extensions").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/clangd_extensions.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/clangd_extensions.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "clangd-extensions",
|
||||
["opts"] = { ["inlay_hints"] = { ["inline"] = false } },
|
||||
@ -149,50 +149,50 @@ require("lazy").setup({
|
||||
["dependencies"] = {
|
||||
{
|
||||
"cmp-async-path",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp-async-path",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp-async-path",
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-async-path",
|
||||
},
|
||||
{
|
||||
"cmp-buffer",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp-buffer",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp-buffer",
|
||||
["enabled"] = false,
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-buffer",
|
||||
},
|
||||
{
|
||||
"cmp-cmdline",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp-cmdline",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp-cmdline",
|
||||
["enabled"] = false,
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-cmdline",
|
||||
},
|
||||
{
|
||||
"cmp-emoji",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp-emoji",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp-emoji",
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-emoji",
|
||||
},
|
||||
{
|
||||
"cmp-nvim-lsp",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp-nvim-lsp",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp-nvim-lsp",
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-nvim-lsp",
|
||||
},
|
||||
{
|
||||
"cmp-nvim-lsp-signature-help",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp-nvim-lsp-signature-help",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp-nvim-lsp-signature-help",
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-nvim-lsp-signature-help",
|
||||
},
|
||||
{
|
||||
"cmp-luasnip",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/cmp_luasnip",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/cmp_luasnip",
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp-luasnip",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-cmp",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-cmp",
|
||||
["event"] = { "InsertEnter" },
|
||||
["lazy"] = true,
|
||||
["name"] = "cmp",
|
||||
@ -262,17 +262,6 @@ require("lazy").setup({
|
||||
}
|
||||
end,
|
||||
},
|
||||
{
|
||||
"colorizer",
|
||||
["config"] = function(_, opts)
|
||||
require("colorizer").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-colorizer.lua",
|
||||
["enabled"] = false,
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "colorizer",
|
||||
},
|
||||
{
|
||||
"comment",
|
||||
["config"] = function(_, opts)
|
||||
@ -287,12 +276,12 @@ require("lazy").setup({
|
||||
|
||||
require("ts_context_commentstring").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-ts-context-commentstring",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-ts-context-commentstring",
|
||||
["lazy"] = true,
|
||||
["name"] = "ts-context-commentstring",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/comment.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/comment.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "comment",
|
||||
["opts"] = {
|
||||
@ -309,7 +298,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("conform").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/conform.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/conform.nvim",
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "conform",
|
||||
@ -343,8 +332,9 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("flash").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/flash.nvim",
|
||||
["lazy"] = false,
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/flash.nvim",
|
||||
["keys"] = { "s", "S", "f", "F", "t", "T" },
|
||||
["lazy"] = true,
|
||||
["name"] = "flash",
|
||||
},
|
||||
{
|
||||
@ -355,7 +345,7 @@ require("lazy").setup({
|
||||
vim.g[k] = v
|
||||
end
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/git-messenger.vim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/git-messenger.vim",
|
||||
["lazy"] = true,
|
||||
["name"] = "gitmessenger",
|
||||
["opts"] = {
|
||||
@ -368,7 +358,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("gitsigns").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/gitsigns.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/gitsigns.nvim",
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "gitsigns",
|
||||
@ -376,7 +366,7 @@ require("lazy").setup({
|
||||
},
|
||||
{
|
||||
"haskell-tools",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/haskell-tools.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/haskell-tools.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "haskell-tools",
|
||||
},
|
||||
@ -385,7 +375,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("illuminate").configure(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/vim-illuminate",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/vim-illuminate",
|
||||
["event"] = { "BufreadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "illuminate",
|
||||
@ -405,7 +395,7 @@ require("lazy").setup({
|
||||
},
|
||||
{
|
||||
"intellitab",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/intellitab.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/intellitab.nvim",
|
||||
["event"] = { "InsertEnter" },
|
||||
["lazy"] = true,
|
||||
["name"] = "intellitab",
|
||||
@ -415,7 +405,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("nvim-lastplace").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-lastplace",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-lastplace",
|
||||
["lazy"] = false,
|
||||
["name"] = "lastplace",
|
||||
},
|
||||
@ -425,12 +415,12 @@ require("lazy").setup({
|
||||
["dependencies"] = {
|
||||
{
|
||||
"plenary",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/plenary.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/plenary.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "plenary",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/lazygit.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/lazygit.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "lazygit",
|
||||
},
|
||||
@ -443,7 +433,7 @@ require("lazy").setup({
|
||||
lint[k] = v
|
||||
end
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-lint",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-lint",
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "lint",
|
||||
@ -468,6 +458,9 @@ require("lazy").setup({
|
||||
"lspconfig",
|
||||
["cmd"] = { "LspInfo" },
|
||||
["config"] = function(_, opts)
|
||||
-- Make LspInfo window border rounded
|
||||
require("lspconfig.ui.windows").default_options.border = "rounded"
|
||||
|
||||
local __lspOnAttach = function(client, bufnr) end
|
||||
|
||||
local __lspCapabilities = function()
|
||||
@ -539,22 +532,16 @@ require("lazy").setup({
|
||||
end,
|
||||
["dependencies"] = {
|
||||
{
|
||||
"neodev",
|
||||
"lazydev",
|
||||
["config"] = function(_, opts)
|
||||
require("neodev").setup(opts)
|
||||
require("lazydev").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/neodev.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "neodev",
|
||||
["opts"] = {
|
||||
["library"] = { ["enabled"] = true, ["plugins"] = true, ["runtime"] = true, ["types"] = true },
|
||||
["lspconfig"] = true,
|
||||
["pathStrict"] = true,
|
||||
["setup_jsonls"] = false,
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/vimplugin-nvim-lazydev",
|
||||
["ft"] = { "lua" },
|
||||
["name"] = "lazydev",
|
||||
},
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-lspconfig",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-lspconfig",
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "lspconfig",
|
||||
@ -572,7 +559,7 @@ require("lazy").setup({
|
||||
unhide = false,
|
||||
})
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/lualine.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/lualine.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "lualine",
|
||||
["opts"] = {
|
||||
@ -599,7 +586,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("luasnip").config.set_config(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/luasnip",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/luasnip",
|
||||
["lazy"] = false,
|
||||
["name"] = "luasnip",
|
||||
},
|
||||
@ -610,20 +597,45 @@ require("lazy").setup({
|
||||
local actions = require("nvim-navbuddy.actions") -- ?
|
||||
require("nvim-navbuddy").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-navbuddy",
|
||||
["lazy"] = true,
|
||||
["name"] = "navbuddy",
|
||||
["opts"] = { ["lsp"] = { ["auto_attach"] = true }, ["window"] = { ["border"] = "rounded" } },
|
||||
},
|
||||
["dependencies"] = {
|
||||
{
|
||||
"navic",
|
||||
["config"] = function(_, opts)
|
||||
require("nvim-navic").setup(opts)
|
||||
navic = require("nvim-navic")
|
||||
navic.setup(opts)
|
||||
|
||||
-- Register navic with lualine's winbar (NOTE: using incline currently)
|
||||
-- TODO: The setup function should probably only be ran once
|
||||
-- require("lualine").setup({
|
||||
-- winbar = {
|
||||
-- lualine_c = {
|
||||
-- {
|
||||
-- function()
|
||||
-- return navic.get_location()
|
||||
-- end,
|
||||
-- cond = function()
|
||||
-- return navic.is_available()
|
||||
-- end
|
||||
-- }
|
||||
-- }
|
||||
-- }
|
||||
-- })
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-navic",
|
||||
["lazy"] = false,
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-navic",
|
||||
["lazy"] = true,
|
||||
["name"] = "navic",
|
||||
["opts"] = { ["click"] = true, ["highlight"] = true, ["lsp"] = { ["auto_attach"] = true } },
|
||||
["opts"] = {
|
||||
["click"] = true,
|
||||
["depth_limit"] = 5,
|
||||
["highlight"] = true,
|
||||
["lsp"] = { ["auto_attach"] = true },
|
||||
},
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-navbuddy",
|
||||
["lazy"] = true,
|
||||
["name"] = "navbuddy",
|
||||
["opts"] = { ["lsp"] = { ["auto_attach"] = true }, ["window"] = { ["border"] = "rounded" } },
|
||||
},
|
||||
{
|
||||
"neo-tree",
|
||||
@ -634,7 +646,7 @@ require("lazy").setup({
|
||||
["dependencies"] = {
|
||||
{
|
||||
"plenary",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/plenary.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/plenary.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "plenary",
|
||||
},
|
||||
@ -643,18 +655,18 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("nvim-web-devicons").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-web-devicons",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-web-devicons",
|
||||
["lazy"] = true,
|
||||
["name"] = "web-devicons",
|
||||
},
|
||||
{
|
||||
"nui",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nui.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nui.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "nui",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/neo-tree.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/neo-tree.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "neo-tree",
|
||||
["opts"] = {
|
||||
@ -697,18 +709,18 @@ require("lazy").setup({
|
||||
vim.notify = require("notify")
|
||||
require("notify").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-notify",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-notify",
|
||||
["lazy"] = true,
|
||||
["name"] = "notify",
|
||||
},
|
||||
{
|
||||
"nui",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nui.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nui.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "nui",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/noice.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/noice.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "noice",
|
||||
["opts"] = {
|
||||
@ -746,25 +758,25 @@ require("lazy").setup({
|
||||
},
|
||||
{
|
||||
"rainbow-delimiters",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/rainbow-delimiters.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/rainbow-delimiters.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "rainbow-delimiters",
|
||||
},
|
||||
{
|
||||
"rustaceanvim",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/rustaceanvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/rustaceanvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "rustaceanvim",
|
||||
},
|
||||
{
|
||||
"sandwich",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/vim-sandwich",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/vim-sandwich",
|
||||
["lazy"] = false,
|
||||
["name"] = "sandwich",
|
||||
},
|
||||
{
|
||||
"sleuth",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/vim-sleuth",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/vim-sleuth",
|
||||
["lazy"] = false,
|
||||
["name"] = "sleuth",
|
||||
},
|
||||
@ -782,30 +794,30 @@ require("lazy").setup({
|
||||
["dependencies"] = {
|
||||
{
|
||||
"plenary",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/plenary.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/plenary.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "plenary",
|
||||
},
|
||||
{
|
||||
"telescope-fzf-native",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/telescope-fzf-native.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/telescope-fzf-native.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "telescope-fzf-native",
|
||||
},
|
||||
{
|
||||
"telescope-undo",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/telescope-undo.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/telescope-undo.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "telescope-undo",
|
||||
},
|
||||
{
|
||||
"telescope-ui-select",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/telescope-ui-select.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/telescope-ui-select.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "telescope-ui-select",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/telescope.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/telescope.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "telescope",
|
||||
["opts"] = {
|
||||
@ -828,12 +840,12 @@ require("lazy").setup({
|
||||
["dependencies"] = {
|
||||
{
|
||||
"plenary",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/plenary.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/plenary.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "plenary",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/todo-comments.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/todo-comments.nvim",
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "todo-comments",
|
||||
@ -844,7 +856,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("toggleterm").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/toggleterm.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/toggleterm.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "toggleterm",
|
||||
["opts"] = {
|
||||
@ -874,7 +886,7 @@ require("lazy").setup({
|
||||
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-treesitter",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-treesitter",
|
||||
["event"] = { "BufReadPost", "BufNewFile" },
|
||||
["lazy"] = true,
|
||||
["name"] = "treesitter",
|
||||
@ -899,7 +911,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("trim").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/trim.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/trim.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "trim",
|
||||
},
|
||||
@ -909,7 +921,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("trouble").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/trouble.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/trouble.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "trouble",
|
||||
},
|
||||
@ -921,12 +933,12 @@ require("lazy").setup({
|
||||
["dependencies"] = {
|
||||
{
|
||||
"promise",
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/promise-async",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/promise-async",
|
||||
["lazy"] = true,
|
||||
["name"] = "promise",
|
||||
},
|
||||
},
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/nvim-ufo",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/nvim-ufo",
|
||||
["lazy"] = false,
|
||||
["name"] = "ufo",
|
||||
},
|
||||
@ -935,7 +947,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("which-key").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/which-key.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/which-key.nvim",
|
||||
["lazy"] = false,
|
||||
["name"] = "which-key",
|
||||
["priority"] = 500,
|
||||
@ -946,7 +958,7 @@ require("lazy").setup({
|
||||
["config"] = function(_, opts)
|
||||
require("yanky").setup(opts)
|
||||
end,
|
||||
["dir"] = "/nix/store/8bx1xnvd173gghqaak7qyfr9ay7vxdw3-lazy-plugins/yanky.nvim",
|
||||
["dir"] = "/nix/store/3c3iq1px7hriyhc3ihk3rl3nnvkrxa92-lazy-plugins/yanky.nvim",
|
||||
["lazy"] = true,
|
||||
["name"] = "yanky",
|
||||
},
|
||||
@ -1028,13 +1040,18 @@ do
|
||||
{ ["action"] = ":m '<-2<cr>gv=gv", ["key"] = "<M-k>", ["mode"] = "v", ["options"] = {
|
||||
["desc"] = "Move line up",
|
||||
} },
|
||||
{ ["action"] = "<cmd>w<cr>", ["key"] = "<C-s>", ["mode"] = "n", ["options"] = {
|
||||
["desc"] = "Save current buffer",
|
||||
} },
|
||||
{ ["action"] = "<cmd>wa<cr>", ["key"] = "<C-S-s>", ["mode"] = "n", ["options"] = {
|
||||
["desc"] = "Save all buffers",
|
||||
} },
|
||||
{ ["action"] = "<Esc>", ["key"] = ";", ["mode"] = "v", ["options"] = { ["desc"] = "Exit visual mode" } },
|
||||
{
|
||||
["action"] = "<cmd>w<cr>",
|
||||
["key"] = "<C-s>",
|
||||
["mode"] = { "n", "i", "v" },
|
||||
["options"] = { ["desc"] = "Save current buffer" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>wa<cr>",
|
||||
["key"] = "<C-S-s>",
|
||||
["mode"] = { "n", "i", "v" },
|
||||
["options"] = { ["desc"] = "Save all buffers" },
|
||||
},
|
||||
{ ["action"] = "<gv", ["key"] = "<", ["mode"] = "v", ["options"] = { ["desc"] = "Outdent" } },
|
||||
{ ["action"] = "v<<Esc>", ["key"] = "<", ["mode"] = "n", ["options"] = { ["desc"] = "Outdent" } },
|
||||
{ ["action"] = ">gv", ["key"] = ">", ["mode"] = "v", ["options"] = { ["desc"] = "Indent" } },
|
||||
@ -1061,6 +1078,18 @@ do
|
||||
["desc"] = "Paste from clipboard",
|
||||
} },
|
||||
{ ["action"] = '"+y', ["key"] = "<C-S-c>", ["mode"] = "v", ["options"] = { ["desc"] = "Copy to clipboard" } },
|
||||
{
|
||||
["action"] = "<cmd>lua require('flash').jump()<cr>",
|
||||
["key"] = "s",
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Flash jump" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>lua require('flash').treesitter()<cr>",
|
||||
["key"] = "S",
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Flash treesitter" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>nohlsearch<cr>",
|
||||
["key"] = "<C-h>",
|
||||
@ -1079,6 +1108,7 @@ do
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Find in current buffer" },
|
||||
},
|
||||
{ ["action"] = "<Esc>", ["key"] = ";", ["mode"] = "v", ["options"] = { ["desc"] = "Exit visual mode" } },
|
||||
{ ["action"] = "<cmd>Lazy<cr>", ["key"] = "<leader>L", ["mode"] = "n", ["options"] = { ["desc"] = "Show Lazy" } },
|
||||
{
|
||||
["action"] = "<cmd>w<cr>",
|
||||
@ -1265,6 +1295,12 @@ do
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Toggle autoformat-on-save" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>ToggleAutoLint<cr>",
|
||||
["key"] = "<leader>tl",
|
||||
["mode"] = "n",
|
||||
["options"] = { ["desc"] = "Toggle autolint-on-save" },
|
||||
},
|
||||
{
|
||||
["action"] = "<cmd>ToggleInlineDiagnostics<cr>",
|
||||
["key"] = "<leader>tD",
|
||||
@ -1397,6 +1433,9 @@ end
|
||||
|
||||
vim.filetype.add({ ["extension"] = { ["v"] = "vlang" } })
|
||||
|
||||
-- Make Lazy window border rounded
|
||||
require("lazy.core.config").options.ui.border = "rounded"
|
||||
|
||||
-- Toggle inline diagnostics and show border
|
||||
vim.g.enable_inline_diagnostics = false
|
||||
vim.diagnostic.config({
|
||||
@ -1434,12 +1473,27 @@ end, {
|
||||
desc = "Print LSP server configuration",
|
||||
})
|
||||
|
||||
-- Toggle linting
|
||||
vim.g.disable_autolint = false
|
||||
vim.api.nvim_create_user_command("ToggleAutoLint", function()
|
||||
vim.g.disable_autolint = not vim.g.disable_autolint
|
||||
if vim.g.disable_autolint then
|
||||
-- vim.diagnostic.reset(vim.api.nvim_get_current_buf())
|
||||
vim.diagnostic.reset() -- Reset for all buffers
|
||||
end
|
||||
require("notify")((vim.g.disable_autolint and "Disabled" or "Enabled") .. " autolint-on-save")
|
||||
end, {
|
||||
desc = "Toggle autolint-on-save",
|
||||
})
|
||||
|
||||
-- Set up autocommands {{
|
||||
do
|
||||
local __nixvim_autocommands = {
|
||||
{
|
||||
["callback"] = function()
|
||||
if not vim.g.disable_autolint then
|
||||
require("lint").try_lint()
|
||||
end
|
||||
end,
|
||||
["event"] = { "BufWritePost" },
|
||||
},
|
||||
|
||||
@ -1,89 +0,0 @@
|
||||
name: Bug Report
|
||||
description: File a bug/issue
|
||||
title: "bug: "
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
**Before** reporting an issue, make sure to read the [documentation](https://github.com/folke/neodev.nvim) and search [existing issues](https://github.com/folke/neodev.nvim/issues). Usage questions such as ***"How do I...?"*** belong in [Discussions](https://github.com/folke/neodev.nvim/discussions) and will be closed.
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Did you check docs and existing issues?
|
||||
description: Make sure you checked all of the below before submitting an issue
|
||||
options:
|
||||
- label: I have read all the neodev.nvim docs
|
||||
required: true
|
||||
- label: I have searched the existing issues of neodev.nvim
|
||||
required: true
|
||||
- label: I have searched the existing issues of plugins related to this issue
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Neovim version (nvim -v)"
|
||||
placeholder: "0.8.0 commit db1b0ee3b30f"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Operating system/version"
|
||||
placeholder: "MacOS 11.5"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear and concise description of what the bug is. Please include any related errors you see in Neovim.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps To Reproduce
|
||||
description: Steps to reproduce the behavior.
|
||||
placeholder: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected Behavior
|
||||
description: A concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Repro
|
||||
description: Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
|
||||
value: |
|
||||
-- DO NOT change the paths and don't remove the colorscheme
|
||||
local root = vim.fn.fnamemodify("./.repro", ":p")
|
||||
|
||||
-- set stdpaths to use .repro
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
end
|
||||
|
||||
-- bootstrap lazy
|
||||
local lazypath = root .. "/plugins/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
-- install plugins
|
||||
local plugins = {
|
||||
"folke/tokyonight.nvim",
|
||||
"folke/neodev.nvim",
|
||||
-- add any other plugins here
|
||||
}
|
||||
require("lazy").setup(plugins, {
|
||||
root = root .. "/plugins",
|
||||
})
|
||||
|
||||
vim.cmd.colorscheme("tokyonight")
|
||||
-- add anything else here
|
||||
render: Lua
|
||||
validations:
|
||||
required: false
|
||||
@ -1,36 +0,0 @@
|
||||
name: Feature Request
|
||||
description: Suggest a new feature
|
||||
title: "feature: "
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Did you check the docs?
|
||||
description: Make sure you read all the docs before submitting a feature request
|
||||
options:
|
||||
- label: I have read all the neodev.nvim docs
|
||||
required: true
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe.
|
||||
description: A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: A clear and concise description of what you want to happen.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: true
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description: A clear and concise description of any alternative solutions or features you've considered.
|
||||
- type: textarea
|
||||
validations:
|
||||
required: false
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context or screenshots about the feature request here.
|
||||
@ -1,72 +0,0 @@
|
||||
name: CI
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
strategy:
|
||||
matrix:
|
||||
# os: [ubuntu-latest, windows-latest]
|
||||
os: [ubuntu-latest]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install Neovim
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/nvim
|
||||
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
|
||||
cd /tmp/nvim
|
||||
chmod a+x ./nvim.appimage
|
||||
./nvim.appimage --appimage-extract
|
||||
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
|
||||
- name: Run Tests
|
||||
run: |
|
||||
nvim --version
|
||||
[ ! -d tests ] && exit 0
|
||||
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
|
||||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
needs: tests
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: panvimdoc
|
||||
uses: kdheepak/panvimdoc@main
|
||||
with:
|
||||
vimdoc: neodev.nvim
|
||||
version: "Neovim >= 0.8.0"
|
||||
demojify: true
|
||||
treesitter: true
|
||||
- name: Push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "chore(build): auto-generate vimdoc"
|
||||
commit_user_name: "github-actions[bot]"
|
||||
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|
||||
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||
release:
|
||||
name: release
|
||||
if: ${{ github.ref == 'refs/heads/main' }}
|
||||
needs:
|
||||
- docs
|
||||
- tests
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: google-github-actions/release-please-action@v3
|
||||
id: release
|
||||
with:
|
||||
release-type: simple
|
||||
package-name: neodev.nvim
|
||||
- uses: actions/checkout@v3
|
||||
- name: tag stable versions
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
run: |
|
||||
git config user.name github-actions[bot]
|
||||
git config user.email github-actions[bot]@users.noreply.github.com
|
||||
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
|
||||
git tag -d stable || true
|
||||
git push origin :stable || true
|
||||
git tag -a stable -m "Last Stable Release"
|
||||
git push origin stable
|
||||
@ -1,64 +0,0 @@
|
||||
name: Types
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# Run this every hour
|
||||
- cron: "0 * * * *"
|
||||
|
||||
jobs:
|
||||
build-types-nightly:
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup ./data
|
||||
run: mkdir ./data
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get -y install doxygen luajit python3-msgpack
|
||||
- name: Install Neovim
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/nvim
|
||||
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
|
||||
cd /tmp/nvim
|
||||
chmod a+x ./nvim.appimage
|
||||
./nvim.appimage --appimage-extract
|
||||
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
|
||||
- name: Generate new docs
|
||||
run: |
|
||||
nvim --version
|
||||
nvim -u NONE -E -R --headless --cmd "set rtp^=." --cmd "packloadall" --cmd "luafile lua/neodev/build/init.lua" --cmd q
|
||||
- name: Push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "chore: auto-generated types for Neovim nightly"
|
||||
commit_user_name: "github-actions[bot]"
|
||||
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|
||||
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||
build-types-stable:
|
||||
needs: build-types-nightly
|
||||
runs-on: ubuntu-22.04
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Pull Updates
|
||||
run: git pull
|
||||
- name: Install Neovim
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/nvim
|
||||
wget -q https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -O /tmp/nvim/nvim.appimage
|
||||
cd /tmp/nvim
|
||||
chmod a+x ./nvim.appimage
|
||||
./nvim.appimage --appimage-extract
|
||||
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
|
||||
- name: Generate new docs
|
||||
run: |
|
||||
nvim --version
|
||||
nvim -u NONE -E -R --headless --cmd "set rtp^=." --cmd "packloadall" --cmd "luafile lua/neodev/build/init.lua" --cmd q
|
||||
- name: Push changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v4
|
||||
with:
|
||||
commit_message: "chore: auto-generated types for Neovim stable"
|
||||
commit_user_name: "github-actions[bot]"
|
||||
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|
||||
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||
@ -1,8 +0,0 @@
|
||||
tt.*
|
||||
.tests
|
||||
doc/tags
|
||||
debug
|
||||
.repro
|
||||
foo.*
|
||||
*.log
|
||||
data
|
||||
@ -1,18 +0,0 @@
|
||||
{
|
||||
"neodev": {
|
||||
"library": {
|
||||
"enabled": true,
|
||||
"plugins": ["neoconf.nvim", "nvim-lspconfig"]
|
||||
}
|
||||
},
|
||||
"neoconf": {
|
||||
"plugins": {
|
||||
"lua_ls": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"lspconfig": {
|
||||
"sumneko_lua": {}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
# Updating Lua API Docs
|
||||
|
||||
1. Clone the neovim repo somewhere on your system
|
||||
2. Run `./scripts/gen_vimdoc.py`
|
||||
3. Copy `neovim/runtime/doc/*.mpack` files to the **neodev.nvim** data directory
|
||||
4. Open the file `neodev.nvim/lua/build/api.lua` in Neovim
|
||||
5. Execute `:luafile %`
|
||||
6. You'll see a lot of annotations that might be changed due to your local
|
||||
system setup, so you can ignore those
|
||||
7. Check if the changes you intended are present
|
||||
8. Create a PR with your code changes, and **without** the new EmmyLua annotations
|
||||
@ -1,266 +0,0 @@
|
||||
# Changelog
|
||||
|
||||
## [2.5.2](https://github.com/folke/neodev.nvim/compare/v2.5.1...v2.5.2) (2023-03-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* parameter type for vim.fn.getline() ([#144](https://github.com/folke/neodev.nvim/issues/144)) ([ab56354](https://github.com/folke/neodev.nvim/commit/ab56354e0e85c3c3f20f770c699fb0038ce7bf42))
|
||||
|
||||
## [2.5.1](https://github.com/folke/neodev.nvim/compare/v2.5.0...v2.5.1) (2023-03-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **lua_ls:** plugin name detection of symlinked plugins ([#140](https://github.com/folke/neodev.nvim/issues/140)) ([a60eaee](https://github.com/folke/neodev.nvim/commit/a60eaee19e0c3dcb7e54c64fe9bcfb71420a95c0))
|
||||
|
||||
## [2.5.0](https://github.com/folke/neodev.nvim/compare/v2.4.2...v2.5.0) (2023-03-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **luv:** use the luv addon instead of the deprecated 3rd party ([f06c113](https://github.com/folke/neodev.nvim/commit/f06c11344f76fadf2cd497b9490125dfc02946cb))
|
||||
|
||||
## [2.4.2](https://github.com/folke/neodev.nvim/compare/v2.4.1...v2.4.2) (2023-03-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* parameter types for searchpair and searchpairpos ([#130](https://github.com/folke/neodev.nvim/issues/130)) ([c87f69c](https://github.com/folke/neodev.nvim/commit/c87f69c856505ea778f6fd883a90397e55c8e59d))
|
||||
|
||||
## [2.4.1](https://github.com/folke/neodev.nvim/compare/v2.4.0...v2.4.1) (2023-02-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* parameter types for vim.wait and vim.fn.input ([#131](https://github.com/folke/neodev.nvim/issues/131)) ([55d3a74](https://github.com/folke/neodev.nvim/commit/55d3a747af136da527067e9fe59ad0bb938ecd50))
|
||||
|
||||
## [2.4.0](https://github.com/folke/neodev.nvim/compare/v2.3.0...v2.4.0) (2023-02-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* added lua_ls luv builtin library. Fixes [#127](https://github.com/folke/neodev.nvim/issues/127) ([8c32d8b](https://github.com/folke/neodev.nvim/commit/8c32d8b4e765de26b27b76f0072e7c12038cde52))
|
||||
|
||||
## [2.3.0](https://github.com/folke/neodev.nvim/compare/v2.2.1...v2.3.0) (2023-02-13)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **luv:** more luv types ([39bb79b](https://github.com/folke/neodev.nvim/commit/39bb79b688300b0b4672ec83c564d72749482116))
|
||||
|
||||
## [2.2.1](https://github.com/folke/neodev.nvim/compare/v2.2.0...v2.2.1) (2023-02-12)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* s/sumneko_lua/lua_ls/ ([#124](https://github.com/folke/neodev.nvim/issues/124)) ([307d0fb](https://github.com/folke/neodev.nvim/commit/307d0fbce02068eebdaa4ef7da279fdb1bfe6d8e))
|
||||
* sumneko_lua -> lua_ls ([5076ebb](https://github.com/folke/neodev.nvim/commit/5076ebbcbfd0e2164d91ff2073a6f21a561804df))
|
||||
|
||||
## [2.2.0](https://github.com/folke/neodev.nvim/compare/v2.1.0...v2.2.0) (2023-02-10)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add more luv methods and types ([#122](https://github.com/folke/neodev.nvim/issues/122)) ([fc01efe](https://github.com/folke/neodev.nvim/commit/fc01efe11447a99808b06e362d95a296218fed68))
|
||||
|
||||
## [2.1.0](https://github.com/folke/neodev.nvim/compare/v2.0.1...v2.1.0) (2023-02-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* Add `treesitter.query` and `treesitter.language` to stable ([#119](https://github.com/folke/neodev.nvim/issues/119)) ([4b6ade9](https://github.com/folke/neodev.nvim/commit/4b6ade9bb879aad4d1b2e94e82c36957262ead53))
|
||||
* add class to vim.api and vim.loop ([e27c03b](https://github.com/folke/neodev.nvim/commit/e27c03b3e312c08e2d4aeed2a0f76199a9729529))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* handle cases where `vim.fn.stdpath("config")` does not exist. Fixes [#109](https://github.com/folke/neodev.nvim/issues/109) ([fc20483](https://github.com/folke/neodev.nvim/commit/fc20483383dac11b97df43c83db1bbbd35305172))
|
||||
* provide a class for vim.api ([#117](https://github.com/folke/neodev.nvim/issues/117)) ([9737bfc](https://github.com/folke/neodev.nvim/commit/9737bfc085cbb8879c19471a65b12fe9bd1ae878))
|
||||
* revert [#117](https://github.com/folke/neodev.nvim/issues/117) ([dd63031](https://github.com/folke/neodev.nvim/commit/dd630312eb978f554006a020554d64c197887644))
|
||||
* use integer for buffer, window, etc ([#116](https://github.com/folke/neodev.nvim/issues/116)) ([71e3e0c](https://github.com/folke/neodev.nvim/commit/71e3e0c2239593e29e06ecc725ba346e29d3186a))
|
||||
|
||||
## [2.0.1](https://github.com/folke/neodev.nvim/compare/v2.0.0...v2.0.1) (2023-01-15)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* ignore lua directory ([82c8586](https://github.com/folke/neodev.nvim/commit/82c85862e2aaa9c0b63f3176eb8dc513803f2865))
|
||||
* **lsp:** make sure everything works when lua root not found. Fixes [#108](https://github.com/folke/neodev.nvim/issues/108) ([31cba85](https://github.com/folke/neodev.nvim/commit/31cba8554a8e37ecf240fa2e242f0e43e72ae930))
|
||||
|
||||
## [2.0.0](https://github.com/folke/neodev.nvim/compare/v1.0.0...v2.0.0) (2023-01-11)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* `config.pathStrict` is now enabled by default. Needs sumneko >= 3.6.0. Much better performance
|
||||
|
||||
### Features
|
||||
|
||||
* **options:** allow setting an option to its type ([1569664](https://github.com/folke/neodev.nvim/commit/156966470d19a8b095f9ae620720be3fb85a3772))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* simplified and improved plugin/config detection ([a34a9e7](https://github.com/folke/neodev.nvim/commit/a34a9e7e775f1513466940c31285292b7b8375de))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* `config.pathStrict` is now enabled by default. Needs sumneko >= 3.6.0. Much better performance ([5ff32d4](https://github.com/folke/neodev.nvim/commit/5ff32d4d50491f94667733362a52d0fe178e4714))
|
||||
|
||||
## 1.0.0 (2023-01-04)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* removed config.plugin_library in favor of config.override for easier customization
|
||||
* rewrite with easier setup and configuration. Backward compatible, but refer to the docs to use the optimized setup
|
||||
|
||||
### Features
|
||||
|
||||
* added [@meta](https://github.com/meta) to generated emmy-lua files ([97a3399](https://github.com/folke/neodev.nvim/commit/97a33996a1618bdc6647384fd605940c5adce743))
|
||||
* added [@see](https://github.com/see) for `seealso` from help docs ([1e8a2b4](https://github.com/folke/neodev.nvim/commit/1e8a2b4427a73cf3f0a51f42c52cc367e71f04f5))
|
||||
* added annotations for vim.filetype, vim.F, vim.fs, vim.health, vim.inspect ([2be3d3f](https://github.com/folke/neodev.nvim/commit/2be3d3ffc17609319090289561842a75dcbf5daf))
|
||||
* added config.runtime() for new vim.fn parser ([87adbea](https://github.com/folke/neodev.nvim/commit/87adbeafc4d2813447e6a75c8f209cb2d637b178))
|
||||
* added configuration option to set the runtime_path (slow). Fixes [#29](https://github.com/folke/neodev.nvim/issues/29) ([f7fecb7](https://github.com/folke/neodev.nvim/commit/f7fecb7deda6fe244b6a5b8edfca21128009baf5))
|
||||
* added docs for options and vim.fn functions ([4eb0e89](https://github.com/folke/neodev.nvim/commit/4eb0e894795251e5381c55ef87e7a0053ad0659c))
|
||||
* added function to check if a fiven fqname is a lua object ([3d1d469](https://github.com/folke/neodev.nvim/commit/3d1d4698a05be1099162812bf7893fb873f6a297))
|
||||
* added luv docs ([e38838a](https://github.com/folke/neodev.nvim/commit/e38838a558a5f80d6a9c8ad7d0044c884254463b))
|
||||
* added missing types ([76e7b48](https://github.com/folke/neodev.nvim/commit/76e7b48122a251b98057cc71823bdc50aa289016))
|
||||
* added option shortnames to vim.opt, o, go, bo, wo, opt_local, opt_global ([309eca5](https://github.com/folke/neodev.nvim/commit/309eca5584eba48d2b77f3668b3c5db3dee7e838))
|
||||
* added options ([9ec4a9c](https://github.com/folke/neodev.nvim/commit/9ec4a9c73b102163055d8d4e52edd833f9c22151))
|
||||
* added overrides for vim.fn.expand and vim.fn.sign_define. Fixes [#72](https://github.com/folke/neodev.nvim/issues/72) ([868db41](https://github.com/folke/neodev.nvim/commit/868db41830bae23c70b4ed044f64f60870bc8f37))
|
||||
* added overrides for vim.fn.glob ([43f51e9](https://github.com/folke/neodev.nvim/commit/43f51e9b86d1637644f0fbba5e1e11bef4341750))
|
||||
* added overrides for vim.loop.new_timer() ([d15370e](https://github.com/folke/neodev.nvim/commit/d15370ee520a169bf6224668ccca175489833948))
|
||||
* added possibility to define [@overload](https://github.com/overload) annotations ([a77f5db](https://github.com/folke/neodev.nvim/commit/a77f5dbfe2e972789c989e2f3909354b482705c0))
|
||||
* added possibility to override auto generated annotations ([9d6b75b](https://github.com/folke/neodev.nvim/commit/9d6b75ba119cf825fb92830188724e6f0f31e4ed))
|
||||
* added support for lazy.nvim ([6136979](https://github.com/folke/neodev.nvim/commit/61369790e4205b74f1667587b3dc5867716500eb))
|
||||
* added support for vim.opt methods. Fixes [#73](https://github.com/folke/neodev.nvim/issues/73) ([9e56a56](https://github.com/folke/neodev.nvim/commit/9e56a56301a297bf8d0c675349c101023a723c22))
|
||||
* added support for vimdoc code blocks ([6d8ce16](https://github.com/folke/neodev.nvim/commit/6d8ce1602a166c03695aaa976252bcb0fd49a7dc))
|
||||
* added types for vim.cmd.* ([9962a1d](https://github.com/folke/neodev.nvim/commit/9962a1dd0db41ab6745be2d9e4b3dc70d1aa188c))
|
||||
* added vim.diagnostic & vim.ui ([58796ba](https://github.com/folke/neodev.nvim/commit/58796ba3f0f7b3ab2197670998555f299cb3f471))
|
||||
* added vim.treesitter.highlighter ([5ca1178](https://github.com/folke/neodev.nvim/commit/5ca117883f37c64ee15f4d6a8ba8ca9a673bfffe))
|
||||
* added vim.treesitter.language ([8d2a950](https://github.com/folke/neodev.nvim/commit/8d2a950045450927d8f7652ef26548b28f3137c8))
|
||||
* added warnings on old-style setup ([17e73ce](https://github.com/folke/neodev.nvim/commit/17e73ce2f9616d5b967e9f3996f3c3b84912ef99))
|
||||
* added workspace support ([681c0fc](https://github.com/folke/neodev.nvim/commit/681c0fc46c49108ec4da9e190c7bfe0ec1393d83))
|
||||
* aded experimental option pathStrict. You need the latest sumneko nightly for this ([60f1ec9](https://github.com/folke/neodev.nvim/commit/60f1ec9d73c7f8fb5537050f38b8921698315e55))
|
||||
* allow config without using lspconfig. Fixes [#83](https://github.com/folke/neodev.nvim/issues/83) ([3b6b644](https://github.com/folke/neodev.nvim/commit/3b6b6442a036729d950f1b92924ac0f5827638ea))
|
||||
* better type infer ([6b9ae84](https://github.com/folke/neodev.nvim/commit/6b9ae848c4b804a9f9179abcc72ee38e824a2fd8))
|
||||
* debug log ([fdab800](https://github.com/folke/neodev.nvim/commit/fdab800ea2a9d4a62b67fe87109b937e6d85f5bf))
|
||||
* docs.fqn ([8f61232](https://github.com/folke/neodev.nvim/commit/8f61232f815e134efdf4cf06e1cd6342f4e369ab))
|
||||
* enable call snippets ([a267319](https://github.com/folke/neodev.nvim/commit/a26731909a6790ab80a4c7bc0c25b8d7402c35e9))
|
||||
* enable lua-dev by default for the Neovim runtime directory when needed ([0001b27](https://github.com/folke/neodev.nvim/commit/0001b27ddce0a1cc620d325577cba9f3b48f9cad))
|
||||
* fix indent of doc comments ([5abb32a](https://github.com/folke/neodev.nvim/commit/5abb32ab07a2e01726095dcc9bf224f874eeac69))
|
||||
* fixed detection of definitions for vim.keymap ([63bdf08](https://github.com/folke/neodev.nvim/commit/63bdf085b17ff55c938763ca1f6c346af119277c))
|
||||
* fixed option docs ([fb82dcc](https://github.com/folke/neodev.nvim/commit/fb82dcc58d7839a60a0da008049dc42c663bebae))
|
||||
* format code blocks as markdown ([e85a190](https://github.com/folke/neodev.nvim/commit/e85a19015ceb8498f6e80cb0094eb2dc45603bde))
|
||||
* full support of vim.go, wo, bo, o, opt, opt_local, opt_global ([261d29c](https://github.com/folke/neodev.nvim/commit/261d29c44328eb4b703e49ba4a6ae4e5297a96fc))
|
||||
* generated types for stable (Neovim 0.8.0) ([4366cad](https://github.com/folke/neodev.nvim/commit/4366cada45729a4224cbdf9b34f085b678c64796))
|
||||
* handle special Lua keywords ([142d456](https://github.com/folke/neodev.nvim/commit/142d456011e0a5df302e5cced535ecaa13be631a))
|
||||
* hidden option to make sumneko use a different neovim runtime for testing ([d55299f](https://github.com/folke/neodev.nvim/commit/d55299fea0655a416d94cb11badcd342ec54d7f4))
|
||||
* implemented optional parameters for lua api functions ([ee8e6af](https://github.com/folke/neodev.nvim/commit/ee8e6af506fc94763c59d336258de48b9f500988))
|
||||
* improved docs.functions ([c3a6a8c](https://github.com/folke/neodev.nvim/commit/c3a6a8c77af8dc04a064fe9b75d68bf3c56e4d4d))
|
||||
* improved vim.api and vim parsers ([60fce6d](https://github.com/folke/neodev.nvim/commit/60fce6dd0c60376f3a2d2253b314c6088ad067a9))
|
||||
* initial version ([26bd607](https://github.com/folke/neodev.nvim/commit/26bd607564940dc56575b792d799366a0da56c1f))
|
||||
* integrate with settings.nvim ([d95e691](https://github.com/folke/neodev.nvim/commit/d95e69166dbbef775140aecd02508db13c3606bb))
|
||||
* integration with neoconf.nvim ([77e8aec](https://github.com/folke/neodev.nvim/commit/77e8aec83549db4f575aa99cd8e2a88ac85db662))
|
||||
* keep original formatting when parsing docs ([6cf4af1](https://github.com/folke/neodev.nvim/commit/6cf4af1a026d63e676bddbdf8ad5b3fd726f1218))
|
||||
* lua-dev is now neodev ([b43d272](https://github.com/folke/neodev.nvim/commit/b43d2726829c0fe2d3950372e13177daaff14ea4))
|
||||
* lua-dev now properly sets up jsonls for .luarc.json, the sumneko local config files ([fb62007](https://github.com/folke/neodev.nvim/commit/fb620072c444404b2b55e9a0d8ba6d6f9e2dac69))
|
||||
* lua.txt doc parser ([0e7a16b](https://github.com/folke/neodev.nvim/commit/0e7a16b070c6be725573bc8cc2b0d69694cefc62))
|
||||
* merge defs of vim._editor in `vim` ([858bcd6](https://github.com/folke/neodev.nvim/commit/858bcd6840fa9578d14915f05fc15ca9b0959517))
|
||||
* merge in lspconfig options ([1f7ee38](https://github.com/folke/neodev.nvim/commit/1f7ee38d0f4e3972c3768e360979f5670aba2070))
|
||||
* more luv annotations ([b50621a](https://github.com/folke/neodev.nvim/commit/b50621a868004292372d91a03c88923b36659d99))
|
||||
* new options parser ([0c65251](https://github.com/folke/neodev.nvim/commit/0c65251ef6f93c795b6d44e339d97670a3500e8b))
|
||||
* new parser ([42e9c51](https://github.com/folke/neodev.nvim/commit/42e9c5126904d6715ece660224610f3a38e4b8d4))
|
||||
* new vim functions parser ([4d9ee97](https://github.com/folke/neodev.nvim/commit/4d9ee97048c6b541c363cc99dce24c3e77527631))
|
||||
* only load missing functions from mpack on nightly. hidden functions ([f0bf928](https://github.com/folke/neodev.nvim/commit/f0bf928719bf1b7eb0ee905e787c29e9a332e25f))
|
||||
* optionally supply a list of plugins to add to the workspace [#2](https://github.com/folke/neodev.nvim/issues/2) ([1fb6cc8](https://github.com/folke/neodev.nvim/commit/1fb6cc81ca98aab4d46ded1d39dcd29a44e48fcc))
|
||||
* parse luv return values from docs ([107b7d9](https://github.com/folke/neodev.nvim/commit/107b7d9413b8134a72ea838a624679f5a4e4fdf9))
|
||||
* proper typing for vim.g, vim.v, vim.b, vim.w and vim.t ([b16231e](https://github.com/folke/neodev.nvim/commit/b16231e7af55be112fcb867fd7b5eddf2993e9da))
|
||||
* properly configure runtime.path to make require work for plugins (slow). Fixes [#23](https://github.com/folke/neodev.nvim/issues/23) ([274f72b](https://github.com/folke/neodev.nvim/commit/274f72b6bc5c199f6d2d33956f9aa0603d4c3367))
|
||||
* properly parse optional params like (*opts) ([48cca93](https://github.com/folke/neodev.nvim/commit/48cca93b6d5da62db8da46c6d81b8fde2f4c8914))
|
||||
* removed config.plugin_library in favor of config.override for easier customization ([46a2eb0](https://github.com/folke/neodev.nvim/commit/46a2eb009062bef889dd05913f92c2c11a57b189))
|
||||
* replace code regions by markdown lua code blocks ([23df3f4](https://github.com/folke/neodev.nvim/commit/23df3f4f5403dbf24ccc1c8fc998db5298a0d377))
|
||||
* rewrite with easier setup and configuration. Backward compatible, but refer to the docs to use the optimized setup ([ae74bc9](https://github.com/folke/neodev.nvim/commit/ae74bc9987638da2e122aaaf155d6519f07e6197))
|
||||
* set correct default option ([e9e1da3](https://github.com/folke/neodev.nvim/commit/e9e1da34d8faa4843fd6d860bc12f552fe2e4a2a))
|
||||
* snippet option for setup ([#47](https://github.com/folke/neodev.nvim/issues/47)) ([8553f1c](https://github.com/folke/neodev.nvim/commit/8553f1c89aa53d2e9bb94b728bdf3ebd0abb625d))
|
||||
* types for nightly ([3e97b3e](https://github.com/folke/neodev.nvim/commit/3e97b3e87fae815863a6276e14af734102d28be8))
|
||||
* types for stable ([499bc32](https://github.com/folke/neodev.nvim/commit/499bc3286050ec5bf2332ee8c6cd726e10e75e6f))
|
||||
* updated all the docs for Neovim 0.6 ([1933c7e](https://github.com/folke/neodev.nvim/commit/1933c7e014e69484572b7fa1bf73bc51c42f10f4))
|
||||
* updated docs to 0.7 ([6063731](https://github.com/folke/neodev.nvim/commit/60637315d665652c59a6a4f99a82f2308d11dd8f))
|
||||
* updated emmy lua files ([5e6caa9](https://github.com/folke/neodev.nvim/commit/5e6caa92b83a07a516d481593344bed1e6eebd6a))
|
||||
* util.error ([c771c04](https://github.com/folke/neodev.nvim/commit/c771c040cb63cdbd2f01ae8698befb64011bbe93))
|
||||
* vim.fn functions ([b1e7776](https://github.com/folke/neodev.nvim/commit/b1e7776e4c7adeaa799002cb8ee25fecdc40f444))
|
||||
* vim.lua for nightly ([cae3dfa](https://github.com/folke/neodev.nvim/commit/cae3dfa0380c9a08a27c947f7de5ee719e087ff2))
|
||||
* vimdoc parser ([ac2a760](https://github.com/folke/neodev.nvim/commit/ac2a7601c8c5d2160512d74746286ea9f9580a09))
|
||||
* when param name is string, and unknown type, then use string ([ddb8162](https://github.com/folke/neodev.nvim/commit/ddb816294b62d7ab76ecbe0f26f2bfb8aef4a5e1))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add correct neovim config directory when pathstrict ([d20c601](https://github.com/folke/neodev.nvim/commit/d20c601836c05039926cbfec0b895a3028af70af))
|
||||
* add lua directories to workspace.library ([563e365](https://github.com/folke/neodev.nvim/commit/563e365b96ea5848e950e216929c08c69d3f4dda))
|
||||
* add vim itself to globals ([2c9311b](https://github.com/folke/neodev.nvim/commit/2c9311b5e45b2ad71843e7e9d49ce31f59cca630))
|
||||
* added .luarc.jsonc validation also to jsonls ([8e2f046](https://github.com/folke/neodev.nvim/commit/8e2f04638f9cb6c297d16c4feef85a6f7615fafb))
|
||||
* added # for parameter docs ([3c7dfda](https://github.com/folke/neodev.nvim/commit/3c7dfda68549b6152bc0aa3c04f81a87ee9af9f9))
|
||||
* added support for builtin libraries and meta/3rd libraries ([8d47e3a](https://github.com/folke/neodev.nvim/commit/8d47e3a488eb8a05f6699036f98f8a9a7f41776b))
|
||||
* added vim.log.levels ([4331626](https://github.com/folke/neodev.nvim/commit/4331626b02f636433b504b9ab6a8c11fb9de4a24))
|
||||
* alias `buffer` type ([#103](https://github.com/folke/neodev.nvim/issues/103)) ([23b58ff](https://github.com/folke/neodev.nvim/commit/23b58ff4e486d32fe9740dcdec0084ee419e1522))
|
||||
* append on_new_config instead of replacing it ([cff0972](https://github.com/folke/neodev.nvim/commit/cff09720d23f84fa4ae46005857d7c5d7a1a4844))
|
||||
* append to existing workspace.library instead of replacing ([b4bc26d](https://github.com/folke/neodev.nvim/commit/b4bc26d91ab17b84e8f15926c18b0c0abea3b690))
|
||||
* better detection of nvim config and plugins where root-dir is incorrect ([d6212c1](https://github.com/folke/neodev.nvim/commit/d6212c1527bb5fb4dbb593318cd937ad2d4d6eee))
|
||||
* better method of finding typed directory [#6](https://github.com/folke/neodev.nvim/issues/6) ([2e1a816](https://github.com/folke/neodev.nvim/commit/2e1a81633bab27e2535d1ccf5f47dda0ba49b0ce))
|
||||
* better package path ([03a44ec](https://github.com/folke/neodev.nvim/commit/03a44ec6a54b0a025a633978e8541584a02e46d9))
|
||||
* broke require path completion again ([9da602d](https://github.com/folke/neodev.nvim/commit/9da602d023ca1af73ac2ea3813798592c904566d))
|
||||
* correctly process global_local options ([2815a2a](https://github.com/folke/neodev.nvim/commit/2815a2acb5a0cd9a11aaadb8256af15c7bf7d513))
|
||||
* docs ([7b96f30](https://github.com/folke/neodev.nvim/commit/7b96f30ca6af998b4e3caa9c3886539e3ae83384))
|
||||
* **docs:** update sumneko_lua setup example ([#67](https://github.com/folke/neodev.nvim/issues/67)) ([8b2b228](https://github.com/folke/neodev.nvim/commit/8b2b228673a88baa9267cb4a9ceb5862b5ee5df4))
|
||||
* don't add arena parameters to functions ([99ee7f2](https://github.com/folke/neodev.nvim/commit/99ee7f21e07f9979b8cf14f24ce24d49aca11494))
|
||||
* don't include lua docs in generated docs. They are correctly set up through `types/vim.lua` ([130b35e](https://github.com/folke/neodev.nvim/commit/130b35e0f671c5729d106a4fe113129cb979e4b1))
|
||||
* don't skip anything from shared, otherwise builtin lua function docs are missing like notify ([24d8cf9](https://github.com/folke/neodev.nvim/commit/24d8cf99ccdaf8ef370f3f2165538fa296cd8122))
|
||||
* dont add root_dir to workspace library. Fixes [#21](https://github.com/folke/neodev.nvim/issues/21) ([e958850](https://github.com/folke/neodev.nvim/commit/e9588503e68fa32ac08b83d9cb7e42ec31b8907d))
|
||||
* fixed lua-dev schema for settings.nvim ([d6900dc](https://github.com/folke/neodev.nvim/commit/d6900dc94a40a3215d1a8debdaaa3036c3df17e5))
|
||||
* fixed requiring files and require path ([3c18da8](https://github.com/folke/neodev.nvim/commit/3c18da83e7d4e4199857721301b9ec52bd99e487))
|
||||
* get all the lua docs for internal lua functions ([6b0d9b0](https://github.com/folke/neodev.nvim/commit/6b0d9b0559defd9840402610824aeb9339ef1319))
|
||||
* improved emmy lua annotations ([4f5a10f](https://github.com/folke/neodev.nvim/commit/4f5a10f192c1fc2b080afc852a85403b1296da8e))
|
||||
* indentation from docs ([a4e5103](https://github.com/folke/neodev.nvim/commit/a4e5103fd91e9db6d9ac924df3fff94eaca8402a))
|
||||
* line context ([fbcdd6d](https://github.com/folke/neodev.nvim/commit/fbcdd6da18c124aa0f36a5981302ff29cd644115))
|
||||
* **luv:** also parse sync return values ([7b495ec](https://github.com/folke/neodev.nvim/commit/7b495ec693ad0bd42268f12f678fdeffa2f62b98))
|
||||
* make options generation deterministic ([136ec0e](https://github.com/folke/neodev.nvim/commit/136ec0eceaef775147034e35c35ff80ad407b7da))
|
||||
* more markdown code blocks ([5b620d9](https://github.com/folke/neodev.nvim/commit/5b620d9059d28ff75aadb50b9a2be80ba0b88272))
|
||||
* more neodev renames ([d23076d](https://github.com/folke/neodev.nvim/commit/d23076d66ab87cf2d2feae7d5ff4f3cf4f0c754d))
|
||||
* move settings to lua-dev ([c62617e](https://github.com/folke/neodev.nvim/commit/c62617ee4f15e04e0e5a96f3a824a3a1c838df53))
|
||||
* mpack functions can have multiple docs ([2c2293c](https://github.com/folke/neodev.nvim/commit/2c2293cede37c19ca2cc8349fafaa8a7fe132f7d))
|
||||
* multi-line comments for parameters ([acfa55b](https://github.com/folke/neodev.nvim/commit/acfa55b291c83e6fa40a006ea824d92d624c11b6))
|
||||
* new settings.nvim API ([6477ca9](https://github.com/folke/neodev.nvim/commit/6477ca95d081e2b2397a993699c8ff643c632f85))
|
||||
* options now have proper types ([d9bd9b4](https://github.com/folke/neodev.nvim/commit/d9bd9b488e83939e746b8150f2b684e72bb1275e))
|
||||
* other way to prevent name change issues ([d3f7002](https://github.com/folke/neodev.nvim/commit/d3f70023d925b0c2e3084bb08a42aad3b2c2f027))
|
||||
* parse incorrect function signatures with missing {} ([7eb0f15](https://github.com/folke/neodev.nvim/commit/7eb0f15fe8eaef3c4204e12cd3a94e183dd8f843))
|
||||
* prepend "lua/" to package path ([b24f225](https://github.com/folke/neodev.nvim/commit/b24f22588eab04d604be7816cf5dfe09f96e7245))
|
||||
* remove duplication of lua/ ([#66](https://github.com/folke/neodev.nvim/issues/66)) ([ec50266](https://github.com/folke/neodev.nvim/commit/ec50266039f0e71178be8c1d22211f48af498efe))
|
||||
* remove root_dir from library. otherwise rename is broken ([b9b721a](https://github.com/folke/neodev.nvim/commit/b9b721a5bed76374ae7d96a6a211737954e241c7))
|
||||
* remove vimconfig from workspace library. not needed [#1](https://github.com/folke/neodev.nvim/issues/1) ([0faabb9](https://github.com/folke/neodev.nvim/commit/0faabb95aec5af07f4416a8adb3ff6a218f6a855))
|
||||
* replace `dict(something)` by `dict`, otherwise sumneko fails to render the hover ([4667d53](https://github.com/folke/neodev.nvim/commit/4667d535e7d811f5003bf57f786a0ce05ce6f516))
|
||||
* replace invalid param name characters ([e5a553c](https://github.com/folke/neodev.nvim/commit/e5a553c6ffd661ab6f42be3f6992baf42f452445))
|
||||
* resolve realpath of neovim config ([42eab7e](https://github.com/folke/neodev.nvim/commit/42eab7e0a7950f0322794a580ff10f56d1d15ee7))
|
||||
* set proper runtime.path for require completion ([7840b31](https://github.com/folke/neodev.nvim/commit/7840b31c020c04076dde9fb9e45a9f653320b3e4))
|
||||
* sort functions before writing ([72c4e61](https://github.com/folke/neodev.nvim/commit/72c4e61a6d69e9907c271893a0822142fda1facf))
|
||||
* sort vim.fn functions before writing file ([cc55fd1](https://github.com/folke/neodev.nvim/commit/cc55fd1b8aa7da0d8f75e2fa711095388fc54f0f))
|
||||
* sumneko library should be a list instead of a dict ([14004d2](https://github.com/folke/neodev.nvim/commit/14004d29ff2d408367b1e6757b0923e67e319325))
|
||||
* types for stable ([901660d](https://github.com/folke/neodev.nvim/commit/901660d70dfa98f1afe9304bf8e580125f591f12))
|
||||
* use correct key for special lsp library paths ([f879e53](https://github.com/folke/neodev.nvim/commit/f879e53f9d4efcc0035a3b395a66ac5794954c74))
|
||||
* use default values for vim.opt ([#87](https://github.com/folke/neodev.nvim/issues/87)) ([66b67cf](https://github.com/folke/neodev.nvim/commit/66b67cf8833a98f5e4f92821e4320be82f160916))
|
||||
* use existing library on settings.Lua.workspace ([cf3b028](https://github.com/folke/neodev.nvim/commit/cf3b028043e86e0e659568aede9d0c8273800b3e))
|
||||
* use lazy.plugins() ([c87f3c9](https://github.com/folke/neodev.nvim/commit/c87f3c9ffb256846e2a51f0292537073ca62d4d0))
|
||||
* workspace.library uses a map ([350b579](https://github.com/folke/neodev.nvim/commit/350b579498a7eeeab33f0ff6496e4fa1d807469a))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* add /lua to plugin directories ([6bf74db](https://github.com/folke/neodev.nvim/commit/6bf74dbe456711d410b905fb5fb4acb87fb4ce0c))
|
||||
* disable callSnippets for now. Too slow ([616b559](https://github.com/folke/neodev.nvim/commit/616b559dff0307adbe62606f806c2b568a6322d5))
|
||||
* disable legacy setup mechanism, but still show warning ([82423f5](https://github.com/folke/neodev.nvim/commit/82423f569d51c79733f5599fb11fb8df46b324d6))
|
||||
* dont use glob to find lua dirs. Check bufs instead. Fixes [#80](https://github.com/folke/neodev.nvim/issues/80) ([97ebf23](https://github.com/folke/neodev.nvim/commit/97ebf23c0d4f5a11f1d68a5abd468751b14980a1))
|
||||
* remove runtime path again. way too slow ([e151df6](https://github.com/folke/neodev.nvim/commit/e151df68973b3aca4c88f6d602f89574d7d32200))
|
||||
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
@ -1,143 +0,0 @@
|
||||
# 💻 neodev.nvim
|
||||
|
||||
Neovim setup for init.lua and plugin development with full signature help, docs and
|
||||
completion for the nvim lua API.
|
||||
|
||||

|
||||
|
||||
## ✨ Features
|
||||
|
||||
- Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin
|
||||
directories
|
||||
- [Annotations](https://github.com/LuaLS/lua-language-server/wiki/Annotations) for completion, hover and signatures of:
|
||||
- Vim functions
|
||||
- Neovim api functions
|
||||
- `vim.opt`
|
||||
- [vim.loop](https://github.com/luvit/luv)
|
||||
- properly configures the `require` path.
|
||||
- adds all plugins in `opt` and `start` to the workspace so you get completion
|
||||
for all installed plugins
|
||||
- properly configure the vim runtime
|
||||
|
||||
## ⚡️ Requirements
|
||||
|
||||
- Neovim >= 0.7.0
|
||||
- completion plugin like [nvim-cmp](https://github.com/hrsh7th/nvim-cmp)
|
||||
|
||||
## 📦 Installation
|
||||
|
||||
Install the plugin with your preferred package manager:
|
||||
|
||||
### [lazy.nvim](https://github.com/folke/lazy.nvim)
|
||||
|
||||
```lua
|
||||
{ "folke/neodev.nvim", opts = {} }
|
||||
```
|
||||
|
||||
### [vim-plug](https://github.com/junegunn/vim-plug)
|
||||
|
||||
```vim
|
||||
Plug 'folke/neodev.nvim'
|
||||
```
|
||||
|
||||
## ⚙️ Configuration
|
||||
|
||||
**neodev** comes with the following defaults:
|
||||
|
||||
```lua
|
||||
{
|
||||
library = {
|
||||
enabled = true, -- when not enabled, neodev will not change any settings to the LSP server
|
||||
-- these settings will be used for your Neovim config directory
|
||||
runtime = true, -- runtime path
|
||||
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
||||
plugins = true, -- installed opt or start plugins in packpath
|
||||
-- you can also specify the list of plugins to make available as a workspace library
|
||||
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
|
||||
},
|
||||
setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files
|
||||
-- for your Neovim config directory, the config.library settings will be used as is
|
||||
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
|
||||
-- for any other directory, config.library.enabled will be set to false
|
||||
override = function(root_dir, options) end,
|
||||
-- With lspconfig, Neodev will automatically setup your lua-language-server
|
||||
-- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init}
|
||||
-- in your lsp start options
|
||||
lspconfig = true,
|
||||
-- much faster, but needs a recent built of lua-language-server
|
||||
-- needs lua-language-server >= 3.6.0
|
||||
pathStrict = true,
|
||||
}
|
||||
```
|
||||
|
||||
## 🚀 Setup
|
||||
|
||||
**neodev** will **ONLY** change the **lua_ls** settings for:
|
||||
|
||||
- your Neovim config directory
|
||||
- your Neovim runtime directory
|
||||
- any plugin directory (this is an lsp root_dir that contains a `/lua`
|
||||
directory)
|
||||
|
||||
For any other `root_dir`, **neodev** will **NOT** change any settings.
|
||||
|
||||
> **TIP** with [neoconf.nvim](https://github.com/folke/neoconf.nvim), you can easily set project local **Neodev** settings.
|
||||
> See the example [.neoconf.json](https://github.com/folke/neodev.nvim/blob/main/.neoconf.json) file in this repository
|
||||
|
||||
```lua
|
||||
-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
|
||||
require("neodev").setup({
|
||||
-- add any options here, or leave empty to use the default settings
|
||||
})
|
||||
|
||||
-- then setup your lsp server as usual
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- example to setup lua_ls and enable call snippets
|
||||
lspconfig.lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Example for setting up **neodev** that overrides the settings for `/etc/nixos`</summary>
|
||||
|
||||
```lua
|
||||
-- You can override the default detection using the override function
|
||||
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
|
||||
require("neodev").setup({
|
||||
override = function(root_dir, library)
|
||||
if root_dir:find("/etc/nixos", 1, true) == 1 then
|
||||
library.enabled = true
|
||||
library.plugins = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
It's possible to setup Neodev without lspconfig, by configuring the `before_init`
|
||||
of the options passed to `vim.lsp.start`.
|
||||
|
||||
<details>
|
||||
<summary>Example without lspconfig</summary>
|
||||
|
||||
```lua
|
||||
-- dont run neodev.setup
|
||||
vim.lsp.start({
|
||||
name = "lua-language-server",
|
||||
cmd = { "lua-language-server" },
|
||||
before_init = require("neodev.lsp").before_init,
|
||||
root_dir = vim.fn.getcwd(),
|
||||
settings = { Lua = {} },
|
||||
})
|
||||
```
|
||||
|
||||
</details>
|
||||
@ -1,163 +0,0 @@
|
||||
*lua-dev.txt* For NVIM v0.5.0 Last change: 2022 October 14
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *lua-dev-table-of-contents*
|
||||
|
||||
1. lua-dev |lua-dev-lua-dev|
|
||||
- Features |lua-dev-features|
|
||||
- Requirements |lua-dev-requirements|
|
||||
- Installation |lua-dev-installation|
|
||||
- Configuration |lua-dev-configuration|
|
||||
- Setup |lua-dev-setup|
|
||||
- How? |lua-dev-how?|
|
||||
|
||||
==============================================================================
|
||||
1. lua-dev *lua-dev-lua-dev*
|
||||
|
||||
Dev setup for init.lua and plugin development with full signature help, docs
|
||||
and completion for the nvim lua API.
|
||||
|
||||
<div class="figure">
|
||||
<img src="https://user-images.githubusercontent.com/292349/118822916-6af02080-b86d-11eb-9990-942fe9b55541.png" title="fig:"/>
|
||||
<p class="caption">image</p>
|
||||
</div>
|
||||
|
||||
<div class="figure">
|
||||
<img src="https://user-images.githubusercontent.com/292349/118823099-9115c080-b86d-11eb-9a68-521c6cb9905a.png" title="fig:"/>
|
||||
<p class="caption">image</p>
|
||||
</div>
|
||||
|
||||
FEATURES *lua-dev-features*
|
||||
|
||||
|
||||
- Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin
|
||||
directories
|
||||
- Annotations <https://github.com/sumneko/lua-language-server/wiki/Annotations> for completion, hover and signatures of:
|
||||
- Vim functions
|
||||
- Neovim api functions
|
||||
- `vim.opt`
|
||||
- vim.loop <https://github.com/luvit/luv>
|
||||
- properly configures the `require` path.
|
||||
- adds all plugins in `opt` and `start` to the workspace so you get completion
|
||||
for all installed plugins
|
||||
- properly configure the vim runtime
|
||||
|
||||
|
||||
REQUIREMENTS *lua-dev-requirements*
|
||||
|
||||
|
||||
- Neovim >= 0.7.0
|
||||
- completion plugin like nvim-cmp <https://github.com/hrsh7th/nvim-cmp>
|
||||
|
||||
|
||||
INSTALLATION *lua-dev-installation*
|
||||
|
||||
Install the plugin with your preferred package manager:
|
||||
|
||||
PACKER <HTTPS://GITHUB.COM/WBTHOMASON/PACKER.NVIM> ~
|
||||
|
||||
>
|
||||
use "folke/lua-dev.nvim"
|
||||
<
|
||||
|
||||
|
||||
VIM-PLUG <HTTPS://GITHUB.COM/JUNEGUNN/VIM-PLUG> ~
|
||||
|
||||
>
|
||||
Plug 'folke/lua-dev.nvim'
|
||||
<
|
||||
|
||||
|
||||
CONFIGURATION *lua-dev-configuration*
|
||||
|
||||
**lua-dev** comes with the following defaults:
|
||||
|
||||
>
|
||||
{
|
||||
library = {
|
||||
enabled = true, -- when not enabled, lua-dev will not change any settings to the LSP server
|
||||
-- these settings will be used for your Neovim config directory
|
||||
runtime = true, -- runtime path
|
||||
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
||||
plugins = true, -- installed opt or start plugins in packpath
|
||||
-- you can also specify the list of plugins to make available as a workspace library
|
||||
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
|
||||
},
|
||||
setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files
|
||||
-- for your Neovim config directory, the config.library settings will be used as is
|
||||
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
|
||||
-- for any other directory, config.library.enabled will be set to false
|
||||
override = function(root_dir, options) end,
|
||||
|
||||
}
|
||||
<
|
||||
|
||||
|
||||
SETUP *lua-dev-setup*
|
||||
|
||||
**lua-dev** will **ONLY** change the **lua_ls** settings for:
|
||||
|
||||
|
||||
- your Neovim config directory
|
||||
- your Neovim runtime directory
|
||||
- any plugin directory (this is an lsp root_dir that contains a `/lua`
|
||||
directory)
|
||||
|
||||
|
||||
For any other `root_dir`, **lua-dev** will **NOT** change any settings.
|
||||
|
||||
>
|
||||
-- IMPORTANT: make sure to setup lua-dev BEFORE lspconfig
|
||||
require("lua-dev").setup({
|
||||
-- add any options here, or leave empty to use the default settings
|
||||
})
|
||||
|
||||
-- then setup your lsp server as usual
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- example to setup sumneko and enable call snippets
|
||||
lspconfig.lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
<
|
||||
|
||||
|
||||
Example for setting up **lua-dev** that overrides the settings for `/etc/nixos`
|
||||
|
||||
>
|
||||
-- You can override the default detection using the override function
|
||||
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
|
||||
require("lua-dev").setup({
|
||||
override = function(root_dir, library)
|
||||
if require("lua-dev.util").has_file(root_dir, "/etc/nixos") then
|
||||
library.enabled = true
|
||||
library.plugins = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
<
|
||||
|
||||
|
||||
HOW? *lua-dev-how?*
|
||||
|
||||
**Neovim** includes a script
|
||||
<https://github.com/neovim/neovim/blob/master/scripts/gen_vimdoc.py> to
|
||||
generate the nvim docs. That script also creates message pack files containing
|
||||
all the API metadata in a structured way. Unfortunately these files are not
|
||||
packaged in the releases.
|
||||
|
||||
Using the message pack files, I converted all the API data to EmmyLua
|
||||
annotations
|
||||
<https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Annotations> and
|
||||
make them available for the Sumneko LSP
|
||||
<https://github.com/sumneko/lua-language-server> as a workspace library.
|
||||
|
||||
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
|
||||
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
@ -1,167 +0,0 @@
|
||||
*neodev.nvim.txt* For Neovim >= 0.8.0 Last change: 2024 March 29
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *neodev.nvim-table-of-contents*
|
||||
|
||||
1. neodev.nvim |neodev.nvim-neodev.nvim|
|
||||
- Features |neodev.nvim-neodev.nvim-features|
|
||||
- Requirements |neodev.nvim-neodev.nvim-requirements|
|
||||
- Installation |neodev.nvim-neodev.nvim-installation|
|
||||
- Configuration |neodev.nvim-neodev.nvim-configuration|
|
||||
- Setup |neodev.nvim-neodev.nvim-setup|
|
||||
2. Links |neodev.nvim-links|
|
||||
|
||||
==============================================================================
|
||||
1. neodev.nvim *neodev.nvim-neodev.nvim*
|
||||
|
||||
Neovim setup for init.lua and plugin development with full signature help, docs
|
||||
and completion for the nvim lua API.
|
||||
|
||||
|
||||
FEATURES *neodev.nvim-neodev.nvim-features*
|
||||
|
||||
- Automatically configures **lua-language-server** for your **Neovim** config, **Neovim** runtime and plugin
|
||||
directories
|
||||
- Annotations <https://github.com/LuaLS/lua-language-server/wiki/Annotations> for completion, hover and signatures of:
|
||||
- Vim functions
|
||||
- Neovim api functions
|
||||
- `vim.opt`
|
||||
- vim.loop <https://github.com/luvit/luv>
|
||||
- properly configures the `require` path.
|
||||
- adds all plugins in `opt` and `start` to the workspace so you get completion
|
||||
for all installed plugins
|
||||
- properly configure the vim runtime
|
||||
|
||||
|
||||
REQUIREMENTS *neodev.nvim-neodev.nvim-requirements*
|
||||
|
||||
- Neovim >= 0.7.0
|
||||
- completion plugin like nvim-cmp <https://github.com/hrsh7th/nvim-cmp>
|
||||
|
||||
|
||||
INSTALLATION *neodev.nvim-neodev.nvim-installation*
|
||||
|
||||
Install the plugin with your preferred package manager:
|
||||
|
||||
|
||||
LAZY.NVIM ~
|
||||
|
||||
>lua
|
||||
{ "folke/neodev.nvim", opts = {} }
|
||||
<
|
||||
|
||||
|
||||
VIM-PLUG ~
|
||||
|
||||
>vim
|
||||
Plug 'folke/neodev.nvim'
|
||||
<
|
||||
|
||||
|
||||
CONFIGURATION *neodev.nvim-neodev.nvim-configuration*
|
||||
|
||||
**neodev** comes with the following defaults:
|
||||
|
||||
>lua
|
||||
{
|
||||
library = {
|
||||
enabled = true, -- when not enabled, neodev will not change any settings to the LSP server
|
||||
-- these settings will be used for your Neovim config directory
|
||||
runtime = true, -- runtime path
|
||||
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
||||
plugins = true, -- installed opt or start plugins in packpath
|
||||
-- you can also specify the list of plugins to make available as a workspace library
|
||||
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
|
||||
},
|
||||
setup_jsonls = true, -- configures jsonls to provide completion for project specific .luarc.json files
|
||||
-- for your Neovim config directory, the config.library settings will be used as is
|
||||
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
|
||||
-- for any other directory, config.library.enabled will be set to false
|
||||
override = function(root_dir, options) end,
|
||||
-- With lspconfig, Neodev will automatically setup your lua-language-server
|
||||
-- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init}
|
||||
-- in your lsp start options
|
||||
lspconfig = true,
|
||||
-- much faster, but needs a recent built of lua-language-server
|
||||
-- needs lua-language-server >= 3.6.0
|
||||
pathStrict = true,
|
||||
}
|
||||
<
|
||||
|
||||
|
||||
SETUP *neodev.nvim-neodev.nvim-setup*
|
||||
|
||||
**neodev** will **ONLY** change the **lua_ls** settings for:
|
||||
|
||||
- your Neovim config directory
|
||||
- your Neovim runtime directory
|
||||
- any plugin directory (this is an lsp root_dir that contains a `/lua`
|
||||
directory)
|
||||
|
||||
For any other `root_dir`, **neodev** will **NOT** change any settings.
|
||||
|
||||
|
||||
**TIP** with neoconf.nvim <https://github.com/folke/neoconf.nvim>, you can
|
||||
easily set project local **Neodev** settings. See the example .neoconf.json
|
||||
<https://github.com/folke/neodev.nvim/blob/main/.neoconf.json> file in this
|
||||
repository
|
||||
>lua
|
||||
-- IMPORTANT: make sure to setup neodev BEFORE lspconfig
|
||||
require("neodev").setup({
|
||||
-- add any options here, or leave empty to use the default settings
|
||||
})
|
||||
|
||||
-- then setup your lsp server as usual
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
-- example to setup lua_ls and enable call snippets
|
||||
lspconfig.lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
completion = {
|
||||
callSnippet = "Replace"
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
<
|
||||
|
||||
Example for setting up **neodev** that overrides the settings for `/etc/nixos` ~
|
||||
|
||||
>lua
|
||||
-- You can override the default detection using the override function
|
||||
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
|
||||
require("neodev").setup({
|
||||
override = function(root_dir, library)
|
||||
if root_dir:find("/etc/nixos", 1, true) == 1 then
|
||||
library.enabled = true
|
||||
library.plugins = true
|
||||
end
|
||||
end,
|
||||
})
|
||||
<
|
||||
|
||||
It’s possible to setup Neodev without lspconfig, by configuring the
|
||||
`before_init` of the options passed to `vim.lsp.start`.
|
||||
|
||||
Example without lspconfig ~
|
||||
|
||||
>lua
|
||||
-- dont run neodev.setup
|
||||
vim.lsp.start({
|
||||
name = "lua-language-server",
|
||||
cmd = { "lua-language-server" },
|
||||
before_init = require("neodev.lsp").before_init,
|
||||
root_dir = vim.fn.getcwd(),
|
||||
settings = { Lua = {} },
|
||||
})
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
2. Links *neodev.nvim-links*
|
||||
|
||||
1. *image*: https://user-images.githubusercontent.com/292349/201495543-ff532160-c8bd-4651-a16f-4fb682c9b945.png
|
||||
|
||||
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
|
||||
|
||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||
@ -1,18 +0,0 @@
|
||||
lua-dev-configuration lua-dev.txt /*lua-dev-configuration*
|
||||
lua-dev-features lua-dev.txt /*lua-dev-features*
|
||||
lua-dev-how? lua-dev.txt /*lua-dev-how?*
|
||||
lua-dev-installation lua-dev.txt /*lua-dev-installation*
|
||||
lua-dev-lua-dev lua-dev.txt /*lua-dev-lua-dev*
|
||||
lua-dev-requirements lua-dev.txt /*lua-dev-requirements*
|
||||
lua-dev-setup lua-dev.txt /*lua-dev-setup*
|
||||
lua-dev-table-of-contents lua-dev.txt /*lua-dev-table-of-contents*
|
||||
lua-dev.txt lua-dev.txt /*lua-dev.txt*
|
||||
neodev.nvim-links neodev.nvim.txt /*neodev.nvim-links*
|
||||
neodev.nvim-neodev.nvim neodev.nvim.txt /*neodev.nvim-neodev.nvim*
|
||||
neodev.nvim-neodev.nvim-configuration neodev.nvim.txt /*neodev.nvim-neodev.nvim-configuration*
|
||||
neodev.nvim-neodev.nvim-features neodev.nvim.txt /*neodev.nvim-neodev.nvim-features*
|
||||
neodev.nvim-neodev.nvim-installation neodev.nvim.txt /*neodev.nvim-neodev.nvim-installation*
|
||||
neodev.nvim-neodev.nvim-requirements neodev.nvim.txt /*neodev.nvim-neodev.nvim-requirements*
|
||||
neodev.nvim-neodev.nvim-setup neodev.nvim.txt /*neodev.nvim-neodev.nvim-setup*
|
||||
neodev.nvim-table-of-contents neodev.nvim.txt /*neodev.nvim-table-of-contents*
|
||||
neodev.nvim.txt neodev.nvim.txt /*neodev.nvim.txt*
|
||||
@ -1,6 +0,0 @@
|
||||
vim.notify(
|
||||
"'lua-dev' was renamed to 'neodev'. Please update your config.",
|
||||
vim.log.levels.WARN,
|
||||
{ title = "neodev.nvim" }
|
||||
)
|
||||
return require("neodev")
|
||||
@ -1,261 +0,0 @@
|
||||
---@class LuaParam
|
||||
---@field name? string
|
||||
---@field type? string
|
||||
---@field doc? string
|
||||
---@field optional? boolean
|
||||
|
||||
--- @class LuaFunction
|
||||
--- @field name string,
|
||||
--- @field doc string,
|
||||
--- @field deprecated? boolean
|
||||
--- @field overload? string[]
|
||||
--- @field params LuaParam[]
|
||||
--- @field return LuaParam[]
|
||||
|
||||
local M = {}
|
||||
|
||||
M.name2type = {
|
||||
boolean = { "set" },
|
||||
buffer = { "buffer", "bufid", "bufnr", "buf" },
|
||||
window = { "win", "window", "winid", "winnr" },
|
||||
number = { "col", "lnum", "tabnr", "nr", "pos", "ns", "index", "from", "to", "start", "stop", "end_", "integer" },
|
||||
string = { "str", "text", "string" },
|
||||
["table<string, any>"] = { "opt", "opts", "options", "dict", "dictionary" },
|
||||
["fun()"] = { "fn", "function", "callback", "func", "funcref", "luaref" },
|
||||
["any[]"] = { "args", "list", "array" },
|
||||
["nil"] = { "void", "none" },
|
||||
}
|
||||
M.keywords =
|
||||
{ "or", "and", "repeat", "function", "end", "return", "do", "break", "else", "elseif", "for", "goto", "if", "while" }
|
||||
M.nvim_types = {
|
||||
window = "integer",
|
||||
buffer = "integer",
|
||||
tabpage = "integer",
|
||||
job = "number",
|
||||
channel = "integer",
|
||||
sends = "number",
|
||||
blob = "number",
|
||||
object = "any",
|
||||
float = "number",
|
||||
}
|
||||
M.lua_types = {
|
||||
["nil"] = "nil",
|
||||
number = "number",
|
||||
string = "string",
|
||||
boolean = "boolean",
|
||||
["function"] = "fun()",
|
||||
table = "table",
|
||||
}
|
||||
|
||||
function M.is_keyword(str)
|
||||
return vim.tbl_contains(M.keywords, str)
|
||||
end
|
||||
|
||||
---@param str string
|
||||
---@param first? string
|
||||
function M.comment(str, first)
|
||||
first = first or ""
|
||||
local prefix = "-- "
|
||||
return first .. prefix .. str:gsub("\n", "\n" .. prefix)
|
||||
end
|
||||
|
||||
---@param param LuaParam
|
||||
function M.type(param)
|
||||
local type = param.type and param.type ~= "" and param.type or "any"
|
||||
|
||||
if type == "any" then
|
||||
for t, names in pairs(M.name2type) do
|
||||
if vim.tbl_contains(names, param.name) then
|
||||
return t
|
||||
end
|
||||
end
|
||||
end
|
||||
for t, names in pairs(M.name2type) do
|
||||
if vim.tbl_contains(names, type) then
|
||||
return t
|
||||
end
|
||||
end
|
||||
|
||||
if M.nvim_types[type] then
|
||||
return type
|
||||
end
|
||||
|
||||
if M.lua_types[type] then
|
||||
return M.lua_types[type]
|
||||
end
|
||||
|
||||
if type == "arrayof(string)" then
|
||||
type = "string[]"
|
||||
elseif type == "arrayof(integer, 2)" then
|
||||
type = "number[]"
|
||||
elseif type == "dictionaryof(luaref)" then
|
||||
type = "table<string, luaref>"
|
||||
elseif type:find("^arrayof%(") then
|
||||
return "any[]"
|
||||
elseif type:find("^dict%(") or type:find("^dictionaryof%(") then
|
||||
return "table<string, any>"
|
||||
end
|
||||
return type
|
||||
end
|
||||
|
||||
---@param param LuaParam
|
||||
function M.param(param)
|
||||
local parts = {}
|
||||
if param.name then
|
||||
if M.is_keyword(param.name) then
|
||||
param.name = param.name .. "_"
|
||||
end
|
||||
table.insert(parts, param.name .. (param.optional and "?" or ""))
|
||||
end
|
||||
|
||||
local type = M.type(param)
|
||||
if type == "nil" then
|
||||
return ""
|
||||
end
|
||||
|
||||
if type then
|
||||
table.insert(parts, type)
|
||||
end
|
||||
|
||||
if param.doc then
|
||||
table.insert(parts, "# " .. param.doc)
|
||||
end
|
||||
|
||||
if not param.doc and type == "any" and not param.optional then
|
||||
return ""
|
||||
end
|
||||
|
||||
local ret = table.concat(parts, " ")
|
||||
if not param.name then
|
||||
return M.comment("@return " .. ret, "-") .. "\n"
|
||||
else
|
||||
return M.comment("@param " .. ret, "-") .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
function M.fqn(name)
|
||||
local real_fn = vim.tbl_get(_G, unpack(vim.split(name, ".", { plain = true })))
|
||||
if vim.api[name] then
|
||||
return "vim.api." .. name
|
||||
elseif vim[name] then
|
||||
return "vim." .. name
|
||||
elseif name:find("^[a-zA-Z_]+$") and vim.fn.exists("*" .. name) == 1 then
|
||||
return "vim.fn." .. name
|
||||
elseif name:find("^vim") and real_fn then
|
||||
return name
|
||||
end
|
||||
-- if we get here, it means the function is RPC only, or no longer exists
|
||||
end
|
||||
|
||||
function M.is_lua(name)
|
||||
local real_fn = vim.tbl_get(_G, unpack(vim.split(name, ".", { plain = true })))
|
||||
|
||||
-- some plugins (like Noice) wrap api functions. This deals with that
|
||||
if real_fn and name:find("vim%.api%.") then
|
||||
return false
|
||||
elseif type(real_fn) == "function" then
|
||||
local info = debug.getinfo(real_fn, "S")
|
||||
return info.what == "Lua"
|
||||
elseif type(real_fn) == "table" then
|
||||
return true
|
||||
elseif not real_fn then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- @param fun LuaFunction
|
||||
function M.fun(fun)
|
||||
local ret = ""
|
||||
if fun.doc ~= "" then
|
||||
-- make markdown lua code blocks for code regions
|
||||
local ft = fun.name:find("vim.fn") and "vim" or "lua"
|
||||
local lines = vim.split(fun.doc, "\n")
|
||||
|
||||
local l = 1
|
||||
while l < #lines do
|
||||
local line = lines[l]
|
||||
local from, to, before, lang = line:find("^(%s*.*)>([a-z]*)%s*$")
|
||||
if from then
|
||||
before = (not before:find("^%s*$")) and before or nil
|
||||
lang = lang ~= "" and lang or nil
|
||||
for i = l + 1, #lines do
|
||||
if lines[i]:find("^%S") or lines[i]:find("^%s*<") or i == #lines then
|
||||
lines[l] = (before and (before .. "\n") or "") .. "```" .. (lang or ft)
|
||||
if lines[i]:find("^%s*<%s*$") then
|
||||
lines[i] = "```"
|
||||
elseif lines[i]:find("^%s*<") then
|
||||
lines[i] = "```\n" .. lines[i]:gsub("<", "")
|
||||
else
|
||||
lines[i] = lines[i] .. "\n```"
|
||||
end
|
||||
l = i
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
l = l + 1
|
||||
end
|
||||
local doc = table.concat(lines, "\n")
|
||||
doc = M.fix_indent(doc)
|
||||
ret = ret .. (M.comment(doc)) .. "\n"
|
||||
end
|
||||
|
||||
if fun.seealso and #fun.seealso > 0 then
|
||||
for _, also in ipairs(fun.seealso) do
|
||||
ret = ret .. "--- @see " .. also .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
local params = {}
|
||||
|
||||
for _, param in pairs(fun.params) do
|
||||
ret = ret .. M.param(param)
|
||||
table.insert(params, param.name)
|
||||
end
|
||||
for _, r in pairs(fun["return"]) do
|
||||
ret = ret .. M.param(r)
|
||||
end
|
||||
|
||||
local signature = "function %s(%s) end"
|
||||
|
||||
-- handle special Lua names. Set as a field instead of a function
|
||||
if M.is_keyword(fun.name:match("[^.]+$")) then
|
||||
local prefix, name = fun.name:match("(.*)%.([^.]+)$")
|
||||
fun.name = name
|
||||
signature = prefix .. "[%q] = function(%s) end"
|
||||
end
|
||||
|
||||
if fun.overload then
|
||||
for _, overload in ipairs(fun.overload) do
|
||||
ret = ret .. "--- @overload " .. overload .. "\n"
|
||||
end
|
||||
end
|
||||
|
||||
ret = ret .. signature:format(fun.name, table.concat(params, ", "))
|
||||
return ret .. "\n\n"
|
||||
end
|
||||
|
||||
---@param text string
|
||||
function M.fix_indent(text)
|
||||
local lines = vim.split(text, "\n")
|
||||
local indent = 10
|
||||
for l, line in ipairs(lines) do
|
||||
if not (line:find("^%s*$") or line:find("^```")) then
|
||||
line = line:gsub(" ", "\t")
|
||||
lines[l] = line
|
||||
local prefix = line:match("^\t+")
|
||||
if prefix then
|
||||
indent = math.min(indent, #prefix)
|
||||
end
|
||||
end
|
||||
end
|
||||
if indent > 0 then
|
||||
for l, line in ipairs(lines) do
|
||||
lines[l] = line:gsub("^" .. ("\t"):rep(indent), ""):gsub("\t", " ")
|
||||
end
|
||||
end
|
||||
return table.concat(lines, "\n")
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,80 +0,0 @@
|
||||
local Annotations = require("neodev.build.annotations")
|
||||
local Docs = require("neodev.build.docs")
|
||||
|
||||
---@class NvimApiInfo
|
||||
---@field functions NvimApiFunction[]
|
||||
|
||||
---@class NvimApiFunction
|
||||
---@field name string
|
||||
---@field deprecated_since? number
|
||||
---@field parameters {[1]: string, [2]:string}[]
|
||||
---@field return_type string
|
||||
---@field since number
|
||||
---@field method? boolean
|
||||
|
||||
---@class LuaApiFunction: LuaFunction
|
||||
---@field params_index? table<string, LuaParam>
|
||||
---@field info? NvimApiFunction
|
||||
|
||||
local M = {}
|
||||
|
||||
---@return table<string, LuaFunction>
|
||||
function M.get()
|
||||
local functions = Docs.parse_functions("api", {
|
||||
name = Annotations.fqn,
|
||||
})
|
||||
---@cast functions table<string, LuaApiFunction>
|
||||
|
||||
-- add params index
|
||||
for _, fun in pairs(functions) do
|
||||
fun.params_index = {}
|
||||
for _, param in ipairs(fun.params) do
|
||||
local name = param.name
|
||||
if name then
|
||||
fun.params_index[name] = param
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@type NvimApiInfo
|
||||
local info = vim.fn.api_info()
|
||||
|
||||
-- add api info
|
||||
for _, fun in ipairs(info.functions) do
|
||||
if not fun.deprecated_since then
|
||||
local name = Annotations.fqn(fun.name)
|
||||
if name then
|
||||
if not functions[name] then
|
||||
functions[name] = {
|
||||
doc = "",
|
||||
name = name,
|
||||
params = {},
|
||||
params_index = {},
|
||||
}
|
||||
end
|
||||
functions[name].info = fun
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- merge api info
|
||||
for _, fun in pairs(functions) do
|
||||
if fun.info then
|
||||
for _, param in ipairs(fun.info.parameters) do
|
||||
if fun.params_index[param[2]] then
|
||||
fun.params_index[param[2]].type = param[1]:lower()
|
||||
else
|
||||
fun.params_index[param[2]] = { name = param[2], type = param[1]:lower() }
|
||||
end
|
||||
end
|
||||
local return_type = fun.info.return_type:lower()
|
||||
fun["return"] = { { type = return_type == "nil" and nil or return_type } }
|
||||
end
|
||||
end
|
||||
|
||||
return functions
|
||||
end
|
||||
|
||||
M.get()
|
||||
|
||||
return M
|
||||
@ -1,340 +0,0 @@
|
||||
local Util = require("neodev.util")
|
||||
local Annotations = require("neodev.build.annotations")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.function_pattern = "^(%S-%([^(]-%))"
|
||||
M.function_signature_pattern = "^(%S-)%(([^(]-)%)"
|
||||
M.vim_type_map = {
|
||||
number = "number",
|
||||
float = "float",
|
||||
string = "string",
|
||||
list = "any[]",
|
||||
any = "any",
|
||||
funcref = "fun()",
|
||||
dict = "table<string, any>",
|
||||
none = "nil",
|
||||
set = "boolean",
|
||||
boolean = "boolean",
|
||||
}
|
||||
|
||||
---@param name string
|
||||
function M.read(name)
|
||||
local docs = vim.fn.expand("$VIMRUNTIME/doc")
|
||||
local txtfile = docs .. "/" .. name .. ".txt"
|
||||
|
||||
---@type string[]
|
||||
local lines = {}
|
||||
for line in io.lines(txtfile) do
|
||||
table.insert(lines, line)
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
---@return string, string[]
|
||||
function M.strip_tags(str)
|
||||
local tags = {}
|
||||
return str
|
||||
:gsub(
|
||||
"(%*%S-%*)",
|
||||
---@param tag string
|
||||
function(tag)
|
||||
tag = tag:sub(2, -2)
|
||||
table.insert(tags, tag)
|
||||
return ""
|
||||
end
|
||||
)
|
||||
:gsub("%s*$", ""),
|
||||
tags
|
||||
end
|
||||
|
||||
---@param text string
|
||||
function M.trim(text)
|
||||
return text:gsub("^%s*\n", ""):gsub("\n+$", "")
|
||||
end
|
||||
|
||||
---@param name string
|
||||
---@param opts { pattern: string, continuation?: string, context?: number}
|
||||
function M.parse(name, opts)
|
||||
opts = opts or {}
|
||||
opts.continuation = opts.continuation or "^[%s<>]"
|
||||
opts.context = opts.context or 1
|
||||
|
||||
local tags = {}
|
||||
local line_tags = {}
|
||||
local chunk_tags = {}
|
||||
local chunk_match = {}
|
||||
local chunk = {}
|
||||
---@type {tags:string[], text:string, match: string[]}[]
|
||||
local ret = {}
|
||||
|
||||
local function save()
|
||||
if #chunk > 0 then
|
||||
table.insert(ret, {
|
||||
tags = vim.deepcopy(chunk_tags),
|
||||
text = M.trim(table.concat(chunk, "\n")),
|
||||
match = vim.deepcopy(chunk_match),
|
||||
})
|
||||
end
|
||||
chunk = {}
|
||||
chunk_tags = {}
|
||||
end
|
||||
local lines = M.read(name)
|
||||
for l, line in ipairs(lines) do
|
||||
line, line_tags = M.strip_tags(line)
|
||||
|
||||
if #line_tags > 0 then
|
||||
tags = line_tags
|
||||
end
|
||||
|
||||
local context = line
|
||||
for c = 1, opts.context do
|
||||
if lines[l + c] then
|
||||
context = context .. "\n" .. lines[l + c]
|
||||
end
|
||||
end
|
||||
|
||||
local match = { context:match(opts.pattern) }
|
||||
|
||||
if #match > 0 then
|
||||
save()
|
||||
chunk_match = match
|
||||
chunk_tags = vim.deepcopy(tags)
|
||||
table.insert(chunk, line)
|
||||
elseif #chunk > 0 and (line:find(opts.continuation) or line:find("^%s*$")) then
|
||||
table.insert(chunk, line)
|
||||
else
|
||||
save()
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---@return {name: string, params: {name:string, optional?:boolean}[], doc: string}?
|
||||
---@return LuaFunction?
|
||||
function M.parse_signature(line)
|
||||
---@type string, string, string
|
||||
local name, sig, doc = line:match(M.function_signature_pattern .. "(.*)")
|
||||
if name then
|
||||
-- Parse args
|
||||
local optional_from = sig:find("%[")
|
||||
sig = sig:gsub("%[", "")
|
||||
sig = sig:gsub("%]", "")
|
||||
sig = sig:gsub("\n", " ")
|
||||
sig = sig:gsub("\t", " ")
|
||||
local params = {}
|
||||
---@type table<string,boolean>
|
||||
local index = {}
|
||||
local from = 0
|
||||
local to = 0
|
||||
local param = ""
|
||||
while from do
|
||||
---@type number, number, string
|
||||
from, to, param = sig:find("{?([^ ,{}]+)}?", to + 1)
|
||||
if from then
|
||||
local optional = optional_from and from >= optional_from and true or nil
|
||||
if param:sub(1, 1) == "*" then
|
||||
optional = true
|
||||
param = param:sub(2)
|
||||
end
|
||||
param = param:gsub("%-", "_")
|
||||
if param:find("^%d+$") then
|
||||
param = "p" .. param
|
||||
end
|
||||
|
||||
-- check for duplicate params
|
||||
local p = param
|
||||
local c = 1
|
||||
while index[param] do
|
||||
param = p .. c
|
||||
c = c + 1
|
||||
end
|
||||
index[param] = true
|
||||
|
||||
table.insert(params, {
|
||||
name = param,
|
||||
optional = optional,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return { name = name, params = params, doc = M.trim(doc) }
|
||||
end
|
||||
end
|
||||
|
||||
function M.options()
|
||||
---@type table<string, string>
|
||||
local ret = {}
|
||||
|
||||
local option_pattern = "^'(%S-)'%s*"
|
||||
|
||||
local options = M.parse("options", { pattern = option_pattern })
|
||||
|
||||
for _, option in ipairs(options) do
|
||||
local name = option.match[1]
|
||||
local doc = option.text:gsub("'(%S-)'", "`'%1'` ")
|
||||
ret[name] = doc
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---@param doc string
|
||||
---@param opts? {filter?: (fun(name:string):boolean), name?: (fun(name:string):string)}
|
||||
function M.parse_functions(doc, opts)
|
||||
opts = opts or {}
|
||||
---@type table<string, LuaFunction>
|
||||
local ret = {}
|
||||
|
||||
local functions = M.parse(doc, { pattern = M.function_pattern, context = 2 })
|
||||
|
||||
for _, fun in ipairs(functions) do
|
||||
local text = fun.text
|
||||
-- replace function name by the function tag, to make sure it is fully qualified
|
||||
for _, tag in ipairs(fun.tags) do
|
||||
if tag:find("vim.*%(%)$") then
|
||||
tag = tag:sub(1, -3)
|
||||
local name = text:match(M.function_signature_pattern)
|
||||
if tag:sub(-#name) == name then
|
||||
text = text:gsub("^%S-%(", tag .. "(")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local parse = M.parse_signature(text)
|
||||
|
||||
if parse then
|
||||
local name = parse.name
|
||||
|
||||
if opts.name then
|
||||
name = opts.name(name)
|
||||
end
|
||||
|
||||
if name and (opts.filter == nil or opts.filter(name)) then
|
||||
ret[name] = {
|
||||
name = name,
|
||||
params = parse.params,
|
||||
doc = parse.doc,
|
||||
["return"] = {},
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.lua()
|
||||
return M.parse_functions("lua", {
|
||||
filter = function(name)
|
||||
return not Annotations.is_lua(name)
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
function M.luv()
|
||||
local ret = M.parse_functions("luvref", {
|
||||
filter = function(name)
|
||||
return not Annotations.is_lua(name)
|
||||
end,
|
||||
name = function(name)
|
||||
local ret = name:gsub("^uv%.", "vim.loop.")
|
||||
return ret
|
||||
end,
|
||||
})
|
||||
Util.for_each(ret, function(_, fun)
|
||||
local returns = fun.doc:match("%s*Returns: (.*)\n")
|
||||
if not returns then
|
||||
returns = fun.doc:match("%s*Returns %(sync version%): (.*)\n")
|
||||
end
|
||||
---@type LuaParam
|
||||
local retval = {}
|
||||
if returns then
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
for t in returns:gmatch("`(.-)`") do
|
||||
if t == "nil" or t == "fail" then
|
||||
retval.optional = true
|
||||
elseif not retval.type then
|
||||
retval.type = t:find("userdata") and "userdata" or t
|
||||
end
|
||||
end
|
||||
end
|
||||
if not vim.tbl_isempty(retval) then
|
||||
fun["return"] = { retval }
|
||||
end
|
||||
end)
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.commands()
|
||||
local pattern = "|:%S-|%s+:([a-z]%S-)%s+(.*)"
|
||||
local builtins = M.parse("index", { pattern = pattern, context = 0, continuation = "^%s+" })
|
||||
---@type table<string,string>
|
||||
local ret = {}
|
||||
for _, builtin in ipairs(builtins) do
|
||||
if vim.tbl_contains(builtin.tags, "ex-cmd-index") then
|
||||
local cmd = builtin.match[1]
|
||||
local desc = builtin.match[2]
|
||||
local i = cmd:find("%[")
|
||||
if i then
|
||||
ret[cmd:sub(1, i - 1)] = desc
|
||||
cmd = cmd:gsub("[%[%]]", "")
|
||||
end
|
||||
ret[cmd] = desc
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.functions()
|
||||
local builtins = M.parse("builtin", { pattern = M.function_pattern, context = 2 })
|
||||
|
||||
---@type table<string, string>
|
||||
local retvals = {}
|
||||
|
||||
-- Parse return values from `:h builtin-function-list`
|
||||
for _, builtin in ipairs(builtins) do
|
||||
if vim.tbl_contains(builtin.tags, "builtin-function-list") then
|
||||
local text = builtin.text
|
||||
-- replace any whitespace after the function by a tab character
|
||||
text = text:gsub(M.function_pattern .. "%s+", "%1\t")
|
||||
-- replace consecutive whitespace by tabs
|
||||
text = text:gsub("%s%s+", "\t")
|
||||
---@type string, string, string
|
||||
local name, _args, retval = text:match(M.function_signature_pattern .. "\t(%w+)")
|
||||
if name then
|
||||
retval = retval:lower()
|
||||
if M.vim_type_map[retval] then
|
||||
retval = M.vim_type_map[retval]
|
||||
if retval ~= "nil" then
|
||||
retvals["vim.fn." .. name] = retval
|
||||
end
|
||||
else
|
||||
Util.debug("Unknown retval: " .. retval)
|
||||
end
|
||||
else
|
||||
Util.error("Couldnt parse builtin-function-list: " .. vim.inspect(builtin))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local ret = M.parse_functions("builtin", {
|
||||
filter = function(name)
|
||||
name = name:match("vim%.fn%.(.*)")
|
||||
if name:find("%.") then
|
||||
return false
|
||||
end
|
||||
return name and (vim.fn.exists("*" .. name) == 1)
|
||||
end,
|
||||
name = function(name)
|
||||
return "vim.fn." .. name
|
||||
end,
|
||||
})
|
||||
for k, fun in pairs(ret) do
|
||||
if retvals[k] then
|
||||
fun["return"] = { { type = retvals[k]:lower() } }
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,126 +0,0 @@
|
||||
local Config = require("neodev.config")
|
||||
local Util = require("neodev.util")
|
||||
|
||||
local Annotations = require("neodev.build.annotations")
|
||||
local Api = require("neodev.build.api")
|
||||
local Docs = require("neodev.build.docs")
|
||||
local Mpack = require("neodev.build.mpack")
|
||||
local Writer = require("neodev.build.writer")
|
||||
local Options = require("neodev.build.options")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.api()
|
||||
local api = Api.get()
|
||||
|
||||
-- Only load mpack on nightly and add any missing functions
|
||||
-- Typically hidden functions
|
||||
if Config.version() == "nightly" then
|
||||
local functions = Mpack.read("api.mpack")
|
||||
|
||||
for k, v in pairs(functions) do
|
||||
if not api[k] then
|
||||
api[k] = v
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.write("api", api)
|
||||
end
|
||||
|
||||
---@return table<string, LuaFunction>, string?
|
||||
function M.override(fname)
|
||||
local override = Config.root("/types/override/" .. fname .. ".lua")
|
||||
if override then
|
||||
local code = Util.read_file(override)
|
||||
local mod = {}
|
||||
local mod_code = code:match("\n(return.*)") or code:match("^(return.*)")
|
||||
if mod_code then
|
||||
mod = load(mod_code)()
|
||||
end
|
||||
code = code:gsub("\nreturn.*", "")
|
||||
code = code:gsub("^return.*", "")
|
||||
return mod, code
|
||||
end
|
||||
return {}
|
||||
end
|
||||
|
||||
---@param fname string
|
||||
---@param functions table<string, LuaFunction>
|
||||
function M.write(fname, functions)
|
||||
local override, override_code = M.override(fname)
|
||||
functions = vim.tbl_deep_extend("force", functions, override)
|
||||
|
||||
local writer = Writer(fname)
|
||||
if override_code then
|
||||
writer:write(override_code .. "\n\n")
|
||||
end
|
||||
Util.for_each(functions, function(_, fun)
|
||||
writer:write(Annotations.fun(fun))
|
||||
end)
|
||||
|
||||
writer:close()
|
||||
end
|
||||
|
||||
function M.alias()
|
||||
local writer = Writer("alias")
|
||||
Util.for_each(Annotations.nvim_types, function(key, value)
|
||||
writer:write(("---@alias %s %s"):format(key, value) .. "\n")
|
||||
end)
|
||||
writer:close()
|
||||
end
|
||||
|
||||
function M.commands()
|
||||
local writer = Writer("cmd")
|
||||
Util.for_each(Docs.commands(), function(cmd, desc)
|
||||
writer:write(Annotations.comment(desc) .. "\n")
|
||||
if Annotations.is_keyword(cmd) then
|
||||
writer:write(("vim.cmd[%q] = function(...)end"):format(cmd) .. "\n\n")
|
||||
else
|
||||
writer:write(("function vim.cmd.%s(...)end"):format(cmd) .. "\n\n")
|
||||
end
|
||||
end)
|
||||
writer:close()
|
||||
end
|
||||
|
||||
function M.clean()
|
||||
local types = Config.types()
|
||||
for _, f in pairs(vim.fn.expand(types .. "/*.lua", false, true)) do
|
||||
if not f:find("/vim.lua", 1, true) then
|
||||
vim.loop.fs_unlink(f)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.uv()
|
||||
local writer = Writer("uv")
|
||||
writer:write(Util.fetch("https://raw.githubusercontent.com/Bilal2453/luvit-meta/main/library/uv.lua"))
|
||||
end
|
||||
|
||||
function M.lpeg()
|
||||
local writer = Writer("lpeg")
|
||||
writer:write(Util.fetch("https://raw.githubusercontent.com/LuaCATS/lpeg/main/library/lpeg.lua"))
|
||||
end
|
||||
|
||||
function M.build()
|
||||
M.clean()
|
||||
M.uv()
|
||||
M.alias()
|
||||
M.commands()
|
||||
|
||||
if vim.fn.has("nvim-0.10") == 0 then
|
||||
M.lpeg()
|
||||
|
||||
Options.build()
|
||||
|
||||
M.api()
|
||||
|
||||
-- M.write("luv", Docs.luv())
|
||||
M.write("lua", Docs.lua())
|
||||
M.write("vim.fn", Docs.functions())
|
||||
end
|
||||
end
|
||||
|
||||
M.build()
|
||||
|
||||
return M
|
||||
@ -1,73 +0,0 @@
|
||||
local Annotations = require("neodev.build.annotations")
|
||||
local util = require("neodev.util")
|
||||
local M = {}
|
||||
|
||||
---@class MpackFunction
|
||||
---@field doc string[]
|
||||
---@field parameters {[1]: string, [2]:string}[]
|
||||
---@field parameters_doc table<string, string>
|
||||
---@field return string[]
|
||||
---@field seealso string[]
|
||||
---@field signature string
|
||||
|
||||
function M.read(mpack)
|
||||
mpack = "data/" .. mpack
|
||||
---@type table<string, MpackFunction>
|
||||
local data = vim.mpack.decode(util.read_file(mpack))
|
||||
|
||||
---@type table<string, LuaFunction>
|
||||
local ret = {}
|
||||
for name, fun in pairs(data) do
|
||||
name = Annotations.fqn(name)
|
||||
if name then
|
||||
ret[name] = M.process(name, fun)
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
---@param name string
|
||||
--- @param fun MpackFunction
|
||||
--- @return LuaFunction
|
||||
function M.process(name, fun)
|
||||
---@type LuaFunction
|
||||
local ret = {
|
||||
doc = (fun.doc and fun.doc[1]) and table.concat(fun.doc, "\n\n") or "",
|
||||
name = name,
|
||||
params = {},
|
||||
seealso = fun.seealso or {},
|
||||
["return"] = {},
|
||||
}
|
||||
|
||||
for _, r in pairs(fun["return"]) do
|
||||
table.insert(ret["return"], { doc = r })
|
||||
end
|
||||
|
||||
for i, p in ipairs(fun.parameters or {}) do
|
||||
local type = p[1]
|
||||
local pname = p[2]
|
||||
local param = { name = pname }
|
||||
if type ~= "" then
|
||||
param.type = type:lower()
|
||||
end
|
||||
param.doc = fun.parameters_doc and fun.parameters_doc[pname] or nil
|
||||
|
||||
if param.type and param.type:find("%*$") then
|
||||
param.type = param.type:sub(1, -2)
|
||||
param.optional = true
|
||||
end
|
||||
-- only include err param if it's documented
|
||||
-- most nvim_ functions have an err param at the end, but these should not be included
|
||||
local skip = i == #fun.parameters and (pname == "err" or pname == "error")
|
||||
-- skip self params
|
||||
if param.name == "self" or param.name == "" or param.name == "arena" then
|
||||
skip = true
|
||||
end
|
||||
if not skip then
|
||||
table.insert(ret.params, param)
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,106 +0,0 @@
|
||||
local Docs = require("neodev.build.docs")
|
||||
local Writer = require("neodev.build.writer")
|
||||
local Annotations = require("neodev.build.annotations")
|
||||
local Util = require("neodev.util")
|
||||
local Config = require("neodev.config")
|
||||
|
||||
---@class OptionInfo
|
||||
---@field allows_duplicates boolean
|
||||
---@field commalist boolean
|
||||
---@field default any
|
||||
---@field flaglist boolean
|
||||
---@field global_local boolean
|
||||
---@field name string
|
||||
---@field scope "global" | "win" | "buf"
|
||||
---@field shortname string
|
||||
---@field type string
|
||||
|
||||
---@alias OptionsInfo table<string, OptionInfo>
|
||||
|
||||
local M = {}
|
||||
|
||||
M.metatype2lua = {
|
||||
map = function(info)
|
||||
return ("table<string, %s>"):format(info.type)
|
||||
end,
|
||||
set = function(info)
|
||||
return ("%s[]"):format(info.type)
|
||||
end,
|
||||
array = function(info)
|
||||
return ("%s[]"):format(info.type)
|
||||
end,
|
||||
}
|
||||
|
||||
function M.build()
|
||||
local writer = Writer("options")
|
||||
|
||||
local docs = Docs.options()
|
||||
|
||||
---@type OptionsInfo
|
||||
local info = vim.api.nvim_get_all_options_info()
|
||||
|
||||
---@param scope string
|
||||
local function write(scope)
|
||||
local var = "vim." .. scope:sub(1, 1) .. "o"
|
||||
|
||||
writer:write("---@class " .. var .. "\n")
|
||||
writer:write(var .. " = {}\n\n")
|
||||
Util.for_each(info, function(name, option)
|
||||
if option.scope == scope then
|
||||
local default = vim.inspect(option.default)
|
||||
local str = ""
|
||||
if docs[name] then
|
||||
str = str .. Annotations.comment(docs[name]) .. "\n"
|
||||
end
|
||||
str = str .. ("%s.%s = %s\n"):format(var, name, default)
|
||||
if option.shortname ~= "" then
|
||||
str = str .. ("%s.%s = %s.%s\n"):format(var, option.shortname, var, name)
|
||||
end
|
||||
writer:write(str)
|
||||
end
|
||||
end)
|
||||
writer:write("\n\n")
|
||||
end
|
||||
|
||||
write("global")
|
||||
write("win")
|
||||
write("buf")
|
||||
|
||||
-- Write vim.opt
|
||||
Util.for_each(info, function(name, option)
|
||||
local str = ""
|
||||
if docs[name] then
|
||||
str = str .. Annotations.comment(docs[name]) .. "\n"
|
||||
end
|
||||
---@type string
|
||||
local return_type = option.type
|
||||
|
||||
pcall(function()
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
return_type = vim.opt[name]._info.metatype
|
||||
if M.metatype2lua[return_type] then
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
return_type = M.metatype2lua[return_type](option)
|
||||
end
|
||||
end)
|
||||
|
||||
str = str .. ("--- @class vim.opt.%s: vim.Option,%s\n"):format(name, return_type)
|
||||
str = str .. ("--- @operator add: vim.opt.%s\n"):format(name)
|
||||
str = str .. ("--- @operator sub: vim.opt.%s\n"):format(name)
|
||||
str = str .. ("--- @operator pow: vim.opt.%s\n"):format(name)
|
||||
str = str .. ("vim.opt.%s = %s\n"):format(name, vim.inspect(option.default))
|
||||
if option.shortname ~= "" then
|
||||
str = str .. ("vim.opt.%s = vim.opt.%s\n"):format(option.shortname, name)
|
||||
end
|
||||
|
||||
str = str .. ("--- @return %s\nfunction vim.opt.%s:get()end\n\n"):format(return_type, name)
|
||||
writer:write(str)
|
||||
end)
|
||||
|
||||
local code = Util.read_file(Config.root("/types/override/options.lua"))
|
||||
writer:write(code .. "\n")
|
||||
|
||||
writer:close()
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,53 +0,0 @@
|
||||
local config = require("neodev.config")
|
||||
|
||||
---@class AnnotationWriter
|
||||
---@field name string
|
||||
---@field fd? number
|
||||
---@field fnum number
|
||||
---@field size number
|
||||
local M = {}
|
||||
M.__index = M
|
||||
|
||||
M.MAX_SIZE = 1024 * 200
|
||||
|
||||
---@return AnnotationWriter
|
||||
function M.new(name)
|
||||
local self = setmetatable({}, M)
|
||||
self.name = name
|
||||
self.size = 0
|
||||
self.fnum = 0
|
||||
return self
|
||||
end
|
||||
|
||||
function M:close()
|
||||
if self.fd then
|
||||
vim.loop.fs_close(self.fd)
|
||||
end
|
||||
end
|
||||
|
||||
function M:check()
|
||||
if not self.fd or self.size > M.MAX_SIZE then
|
||||
self:close()
|
||||
local types = config.types()
|
||||
local fname = types .. "/" .. self.name
|
||||
if self.fnum > 0 then
|
||||
fname = fname .. "." .. self.fnum
|
||||
end
|
||||
self.fd = vim.loop.fs_open(fname .. ".lua", "w+", 420)
|
||||
self.fnum = self.fnum + 1
|
||||
self.size = 0
|
||||
self:intro()
|
||||
end
|
||||
end
|
||||
|
||||
function M:intro()
|
||||
self:write("---@meta\n\n")
|
||||
end
|
||||
|
||||
function M:write(text)
|
||||
self:check()
|
||||
vim.loop.fs_write(self.fd, text, -1)
|
||||
self.size = self.size + #text
|
||||
end
|
||||
|
||||
return M.new
|
||||
@ -1,57 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
--- @class LuaDevOptions
|
||||
M.defaults = {
|
||||
library = {
|
||||
enabled = true, -- when not enabled, neodev will not change any settings to the LSP server
|
||||
-- these settings will be used for your neovim config directory
|
||||
runtime = true, -- runtime path
|
||||
types = true, -- full signature, docs and completion of vim.api, vim.treesitter, vim.lsp and others
|
||||
---@type boolean|string[]
|
||||
plugins = true, -- installed opt or start plugins in packpath
|
||||
-- you can also specify the list of plugins to make available as a workspace library
|
||||
-- plugins = { "nvim-treesitter", "plenary.nvim", "telescope.nvim" },
|
||||
},
|
||||
setup_jsonls = true, -- configures jsonls to provide completion for .luarc.json files
|
||||
-- for your neovim config directory, the config.library settings will be used as is
|
||||
-- for plugin directories (root_dirs having a /lua directory), config.library.plugins will be disabled
|
||||
-- for any other directory, config.library.enabled will be set to false
|
||||
override = function(root_dir, options) end,
|
||||
-- With lspconfig, Neodev will automatically setup your lua-language-server
|
||||
-- If you disable this, then you have to set {before_init=require("neodev.lsp").before_init}
|
||||
-- in your lsp start options
|
||||
lspconfig = true,
|
||||
-- much faster, but needs a recent built of lua-language-server
|
||||
-- needs lua-language-server >= 3.6.0
|
||||
pathStrict = true,
|
||||
debug = false,
|
||||
}
|
||||
|
||||
--- @type LuaDevOptions
|
||||
M.options = {}
|
||||
|
||||
function M.setup(options)
|
||||
M.options = vim.tbl_deep_extend("force", {}, M.defaults, options or {})
|
||||
end
|
||||
|
||||
function M.types()
|
||||
return M.root("/types/" .. M.version())
|
||||
end
|
||||
|
||||
---@param root? string
|
||||
function M.root(root)
|
||||
local f = debug.getinfo(1, "S").source:sub(2)
|
||||
return vim.loop.fs_realpath(vim.fn.fnamemodify(f, ":h:h:h") .. "/" .. (root or ""))
|
||||
end
|
||||
|
||||
---@return "nightly" | "stable"
|
||||
function M.version()
|
||||
return vim.version().prerelease and "nightly" or "stable"
|
||||
end
|
||||
|
||||
---@return LuaDevOptions
|
||||
function M.merge(options)
|
||||
return vim.tbl_deep_extend("force", {}, M.options, options or {})
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,39 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
local function neoconf(config)
|
||||
pcall(function()
|
||||
require("neoconf.plugins").register({
|
||||
on_schema = function(schema)
|
||||
schema:import("neodev", config.defaults)
|
||||
schema:set("neodev.library.plugins", {
|
||||
description = "true/false or an array of plugin names to enable",
|
||||
anyOf = {
|
||||
{ type = "boolean" },
|
||||
{ type = "array", items = { type = "string" } },
|
||||
},
|
||||
})
|
||||
end,
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
---@param opts? LuaDevOptions
|
||||
function M.setup(opts)
|
||||
local config = require("neodev.config")
|
||||
config.setup(opts)
|
||||
|
||||
if config.options.lspconfig then
|
||||
require("neodev.lsp").setup()
|
||||
end
|
||||
|
||||
neoconf(config)
|
||||
|
||||
-- leave this for now for backward compatibility
|
||||
return {
|
||||
settings = {
|
||||
legacy = true,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,115 +0,0 @@
|
||||
local util = require("neodev.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local opts = require("neodev.config").options
|
||||
|
||||
local lsputil = require("lspconfig.util")
|
||||
local hook = lsputil.add_hook_after
|
||||
lsputil.on_setup = hook(lsputil.on_setup, function(config)
|
||||
if opts.setup_jsonls and config.name == "jsonls" then
|
||||
M.setup_jsonls(config)
|
||||
end
|
||||
if config.name == "lua_ls" then
|
||||
config.on_new_config = hook(config.on_new_config, M.on_new_config)
|
||||
-- config.before_init = hook(config.before_init, M.before_init)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function M.setup_jsonls(config)
|
||||
local schemas = config.settings.json and config.settings.json.schemas or {}
|
||||
table.insert(schemas, {
|
||||
name = "LuaLS Settings",
|
||||
url = "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
|
||||
fileMatch = { ".luarc.json", ".luarc.jsonc" },
|
||||
})
|
||||
config.settings = vim.tbl_deep_extend("force", config.settings, {
|
||||
json = {
|
||||
schemas = schemas,
|
||||
validate = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function M.before_init(params, config)
|
||||
M.on_new_config(config, params.rootPath)
|
||||
end
|
||||
|
||||
function M.on_new_config(config, root_dir)
|
||||
-- don't do anything when old style setup was used
|
||||
if config.settings.legacy then
|
||||
util.warn(
|
||||
"You're using the old way of setting up neodev (previously lua-dev).\nPlease check the docs at https://github.com/folke/neodev.nvim#-setup"
|
||||
)
|
||||
return
|
||||
end
|
||||
|
||||
local lua_root = util.find_root()
|
||||
|
||||
local opts = require("neodev.config").merge()
|
||||
|
||||
opts.library.enabled = util.is_nvim_config()
|
||||
|
||||
if not opts.library.enabled and lua_root then
|
||||
opts.library.enabled = true
|
||||
opts.library.plugins = false
|
||||
end
|
||||
|
||||
pcall(function()
|
||||
opts = require("neoconf").get("neodev", opts, { file = root_dir })
|
||||
end)
|
||||
|
||||
pcall(opts.override, root_dir, opts.library)
|
||||
|
||||
local library = config.settings
|
||||
and config.settings.Lua
|
||||
and config.settings.Lua.workspace
|
||||
and config.settings.Lua.workspace.library
|
||||
or {}
|
||||
|
||||
local ignoreDir = config.settings
|
||||
and config.settings.Lua
|
||||
and config.settings.Lua.workspace
|
||||
and config.settings.Lua.workspace.ignoreDir
|
||||
or {}
|
||||
|
||||
if opts.library.enabled then
|
||||
config.handlers = vim.tbl_extend("force", {}, config.handlers or {})
|
||||
config.handlers["workspace/configuration"] = config.handlers["workspace/configuration"]
|
||||
or function(err, result, ctx, cfg)
|
||||
local ret = vim.lsp.handlers["workspace/configuration"](err, result, ctx, cfg)
|
||||
ret = vim.deepcopy(ret)
|
||||
-- when scopeUri is not set, then the requested config is for the fallback scope
|
||||
-- Don't set workspace libraries for the fallback scope
|
||||
-- Thanks to: https://github.com/LuaLS/lua-language-server/issues/1596#issuecomment-1855087288
|
||||
for i, item in ipairs(result.items) do
|
||||
if type(ret[i]) == "table" then
|
||||
if not item.scopeUri and ret[i].workspace then
|
||||
ret[i].workspace.library = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
config.settings =
|
||||
vim.tbl_deep_extend("force", config.settings or {}, require("neodev.luals").setup(opts, config.settings).settings)
|
||||
for _, lib in ipairs(library) do
|
||||
table.insert(config.settings.Lua.workspace.library, lib)
|
||||
end
|
||||
|
||||
if require("neodev.config").options.pathStrict and lua_root then
|
||||
table.insert(config.settings.Lua.workspace.library, lua_root)
|
||||
end
|
||||
|
||||
for _, dir in ipairs(ignoreDir) do
|
||||
table.insert(config.settings.Lua.workspace.ignoreDir, dir)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,110 +0,0 @@
|
||||
local config = require("neodev.config")
|
||||
|
||||
local M = {}
|
||||
|
||||
---@param opts LuaDevOptions
|
||||
function M.library(opts)
|
||||
opts = config.merge(opts)
|
||||
local ret = {}
|
||||
|
||||
if opts.library.types then
|
||||
table.insert(ret, config.types())
|
||||
end
|
||||
|
||||
local function add(lib, filter)
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
for _, p in ipairs(vim.fn.expand(lib .. "/lua", false, true)) do
|
||||
local plugin_name = vim.fn.fnamemodify(p, ":h:t")
|
||||
p = vim.loop.fs_realpath(p)
|
||||
if p and (not filter or filter[plugin_name]) then
|
||||
if config.options.pathStrict then
|
||||
table.insert(ret, p)
|
||||
else
|
||||
table.insert(ret, vim.fn.fnamemodify(p, ":h"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if opts.library.runtime then
|
||||
add(type(opts.library.runtime) == "string" and opts.library.runtime or "$VIMRUNTIME")
|
||||
end
|
||||
|
||||
if opts.library.plugins then
|
||||
---@type table<string, boolean>
|
||||
local filter
|
||||
if type(opts.library.plugins) == "table" then
|
||||
filter = {}
|
||||
for _, p in pairs(opts.library.plugins) do
|
||||
filter[p] = true
|
||||
end
|
||||
end
|
||||
for _, site in pairs(vim.split(vim.o.packpath, ",")) do
|
||||
add(site .. "/pack/*/opt/*", filter)
|
||||
add(site .. "/pack/*/start/*", filter)
|
||||
end
|
||||
-- add support for lazy.nvim
|
||||
if package.loaded["lazy"] then
|
||||
for _, plugin in ipairs(require("lazy").plugins()) do
|
||||
add(plugin.dir, filter)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
---@param settings? lspconfig.settings.lua_ls
|
||||
function M.path(settings)
|
||||
if config.options.pathStrict then
|
||||
return { "?.lua", "?/init.lua" }
|
||||
end
|
||||
|
||||
settings = settings or {}
|
||||
local runtime = settings.Lua and settings.Lua.runtime or {}
|
||||
local meta = runtime.meta or "${version} ${language} ${encoding}"
|
||||
meta = meta:gsub("%${version}", runtime.version or "LuaJIT")
|
||||
meta = meta:gsub("%${language}", "en-us")
|
||||
meta = meta:gsub("%${encoding}", runtime.fileEncoding or "utf8")
|
||||
|
||||
return {
|
||||
-- paths for builtin libraries
|
||||
("meta/%s/?.lua"):format(meta),
|
||||
("meta/%s/?/init.lua"):format(meta),
|
||||
-- paths for meta/3rd libraries
|
||||
"library/?.lua",
|
||||
"library/?/init.lua",
|
||||
-- Neovim lua files, config and plugins
|
||||
"lua/?.lua",
|
||||
"lua/?/init.lua",
|
||||
}
|
||||
end
|
||||
|
||||
---@param opts? LuaDevOptions
|
||||
---@param settings? lspconfig.settings.lua_ls
|
||||
function M.setup(opts, settings)
|
||||
opts = config.merge(opts)
|
||||
return {
|
||||
---@type lspconfig.settings.lua_ls
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = "LuaJIT",
|
||||
path = M.path(settings),
|
||||
pathStrict = config.options.pathStrict,
|
||||
},
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
completion = opts.snippet and { callSnippet = "Replace" } or nil,
|
||||
workspace = {
|
||||
-- Make the server aware of Neovim runtime files
|
||||
library = M.library(opts),
|
||||
-- when pathStrict=false, we need to add the other types to ignoreDir,
|
||||
-- otherwise they get indexed
|
||||
ignoreDir = { config.version() == "stable" and "types/nightly" or "types/stable", "lua" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1,87 +0,0 @@
|
||||
local config = require("neodev.config")
|
||||
|
||||
local M = {}
|
||||
|
||||
--- find the root directory that has /lua
|
||||
---@param path string?
|
||||
---@return string?
|
||||
function M.find_root(path)
|
||||
path = path or vim.api.nvim_buf_get_name(0)
|
||||
return vim.fs.find({ "lua" }, { path = path, upward = true, type = "directory" })[1]
|
||||
end
|
||||
|
||||
function M.fetch(url)
|
||||
local fd = io.popen(string.format("curl -s -k %q", url))
|
||||
if not fd then
|
||||
error(("Could not download %s"):format(url))
|
||||
end
|
||||
local ret = fd:read("*a")
|
||||
fd:close()
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.is_nvim_config()
|
||||
local path = vim.loop.fs_realpath(vim.api.nvim_buf_get_name(0))
|
||||
if path then
|
||||
path = vim.fs.normalize(path)
|
||||
local config_root = vim.loop.fs_realpath(vim.fn.stdpath("config")) or vim.fn.stdpath("config")
|
||||
config_root = vim.fs.normalize(config_root)
|
||||
return path:find(config_root, 1, true) == 1
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function M.keys(tbl)
|
||||
local ret = vim.tbl_keys(tbl)
|
||||
table.sort(ret)
|
||||
return ret
|
||||
end
|
||||
|
||||
---@generic K
|
||||
---@generic V
|
||||
---@param tbl table<K, V>
|
||||
---@param fn fun(key: K, value: V)
|
||||
function M.for_each(tbl, fn)
|
||||
local keys = M.keys(tbl)
|
||||
for _, key in ipairs(keys) do
|
||||
fn(key, tbl[key])
|
||||
end
|
||||
end
|
||||
|
||||
---@param file string
|
||||
---@param flags? string
|
||||
---@return string
|
||||
function M.read_file(file, flags)
|
||||
local fd = io.open(file, "r" .. (flags or ""))
|
||||
if not fd then
|
||||
error(("Could not open file %s for reading"):format(file))
|
||||
end
|
||||
local data = fd:read("*a")
|
||||
fd:close()
|
||||
return data
|
||||
end
|
||||
|
||||
function M.write_file(file, data)
|
||||
local fd = io.open(file, "w+")
|
||||
if not fd then
|
||||
error(("Could not open file %s for writing"):format(file))
|
||||
end
|
||||
fd:write(data)
|
||||
fd:close()
|
||||
end
|
||||
|
||||
function M.debug(msg)
|
||||
if config.options.debug then
|
||||
M.error(msg)
|
||||
end
|
||||
end
|
||||
|
||||
function M.error(msg)
|
||||
vim.notify_once(msg, vim.log.levels.ERROR, { title = "neodev.nvim" })
|
||||
end
|
||||
|
||||
function M.warn(msg)
|
||||
vim.notify_once(msg, vim.log.levels.WARN, { title = "neodev.nvim" })
|
||||
end
|
||||
|
||||
return M
|
||||
@ -1 +0,0 @@
|
||||
std="lua51+vim"
|
||||
@ -1,3 +0,0 @@
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 120
|
||||
@ -1,11 +0,0 @@
|
||||
---@meta
|
||||
|
||||
---@alias blob number
|
||||
---@alias buffer integer
|
||||
---@alias channel integer
|
||||
---@alias float number
|
||||
---@alias job number
|
||||
---@alias object any
|
||||
---@alias sends number
|
||||
---@alias tabpage integer
|
||||
---@alias window integer
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@
|
||||
---@meta
|
||||
|
||||
vim = {}
|
||||
|
||||
---@type uv
|
||||
vim.loop = {}
|
||||
|
||||
vim.F = require("vim.F")
|
||||
vim.diagnostic = require("vim.diagnostic")
|
||||
vim.filetype = require("vim.filetype")
|
||||
vim.fs = require("vim.fs")
|
||||
vim.health = require("vim.health")
|
||||
vim.highlight = require("vim.highlight")
|
||||
vim.inspect = require("vim.inspect").inspect
|
||||
vim.iter = require("vim.iter")
|
||||
vim.keymap = require("vim.keymap")
|
||||
vim.lsp = require("vim.lsp")
|
||||
vim.secure = require("vim.secure")
|
||||
vim.treesitter = require("vim.treesitter")
|
||||
vim.treesitter.highlighter = require("vim.treesitter.highlighter")
|
||||
vim.treesitter.language = require("vim.treesitter.language")
|
||||
vim.treesitter.query = require("vim.treesitter.query")
|
||||
vim.ui = require("vim.ui")
|
||||
vim.uri_from_bufnr = require("vim.uri").uri_from_bufnr
|
||||
vim.uri_from_fname = require("vim.uri").uri_from_fname
|
||||
vim.uri_to_bufnr = require("vim.uri").uri_to_bufnr
|
||||
vim.uri_to_fname = require("vim.uri").uri_to_fname
|
||||
vim.version = require("vim.version")
|
||||
vim.lpeg = require("lpeg")
|
||||
|
||||
---@type table<string,any>
|
||||
vim.g = {}
|
||||
---@type table<string,any>
|
||||
vim.v = {}
|
||||
---@type table<number,table<string, any>>
|
||||
vim.b = {}
|
||||
---@type table<number,table<string, any>>
|
||||
vim.w = {}
|
||||
---@type table<number,table<string, any>>
|
||||
vim.t = {}
|
||||
@ -1,2 +0,0 @@
|
||||
---@class vim.api
|
||||
vim.api = {}
|
||||
@ -1,13 +0,0 @@
|
||||
return {
|
||||
["vim.wait"] = {
|
||||
params = {
|
||||
{ name = "time", type = "number" },
|
||||
{ name = "condition", type = "fun(): boolean", optional = true },
|
||||
{ name = "interval", type = "number", optional = true },
|
||||
{ name = "fast_only", type = "boolean", optional = true },
|
||||
},
|
||||
["return"] = {
|
||||
{ type = "boolean, nil|number" },
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
---@type table<number, vim.go>
|
||||
vim.go = {}
|
||||
|
||||
---@type table<number, vim.bo>
|
||||
vim.bo = {}
|
||||
|
||||
---@type table<number, vim.wo>
|
||||
vim.wo = {}
|
||||
|
||||
---@type vim.go | vim.wo | vim.bo
|
||||
vim.o = {}
|
||||
|
||||
---@class vim.opt
|
||||
vim.opt = {}
|
||||
|
||||
---@type vim.opt
|
||||
vim.opt_global = {}
|
||||
|
||||
---@type vim.opt
|
||||
vim.opt_local = {}
|
||||
|
||||
---@class vim.Option
|
||||
local Option = {}
|
||||
|
||||
function Option:append(right) end
|
||||
function Option:prepend(right) end
|
||||
function Option:remove(right) end
|
||||
@ -1,73 +0,0 @@
|
||||
return {
|
||||
["vim.fn.getline"] = {
|
||||
params = {
|
||||
{ name = "lnum", type = "number|string" },
|
||||
},
|
||||
overload = {
|
||||
"fun(lnum:number|string, end:number|string):string[]|nil[]",
|
||||
},
|
||||
["return"] = {
|
||||
{ type = "string" },
|
||||
},
|
||||
},
|
||||
["vim.fn.expand"] = {
|
||||
params = {
|
||||
{ name = "string", type = "string" },
|
||||
{ name = "nosuf", type = "boolean", optional = true },
|
||||
},
|
||||
overload = {
|
||||
"fun(string:string, nosuf?:boolean, list:true):string[]",
|
||||
},
|
||||
["return"] = {
|
||||
{ type = "string" },
|
||||
},
|
||||
},
|
||||
["vim.fn.glob"] = {
|
||||
params = {
|
||||
{ name = "expr", type = "string" },
|
||||
{ name = "nosuf", type = "boolean", optional = true },
|
||||
},
|
||||
overload = {
|
||||
"fun(expr:string, nosuf?:boolean, list:true):string[]",
|
||||
"fun(expr:string, nosuf?:boolean, list:true, alllinks:true):string[]",
|
||||
},
|
||||
["return"] = {
|
||||
{ type = "string" },
|
||||
},
|
||||
},
|
||||
["vim.fn.sign_define"] = {
|
||||
overload = {
|
||||
"fun(name:string, dict?:table)",
|
||||
},
|
||||
},
|
||||
["vim.fn.input"] = {
|
||||
params = {
|
||||
{ name = "opts", type = "string|table<string, any>" },
|
||||
},
|
||||
["return"] = {
|
||||
{ type = "string" },
|
||||
},
|
||||
},
|
||||
["vim.fn.searchpair"] = {
|
||||
params = {
|
||||
{ name = "start", type = "string" },
|
||||
{ name = "middle", type = "string", optional = true },
|
||||
{ name = "end", type = "string" },
|
||||
{ name = "flags", type = "string", optional = true },
|
||||
{ name = "skip", type = "string", optional = true },
|
||||
{ name = "stopline", type = "number", optional = true },
|
||||
{ name = "timeout", type = "number", optional = true },
|
||||
},
|
||||
},
|
||||
["vim.fn.searchpairpos"] = {
|
||||
params = {
|
||||
{ name = "start", type = "string" },
|
||||
{ name = "middle", type = "string", optional = true },
|
||||
{ name = "end", type = "string" },
|
||||
{ name = "flags", type = "string", optional = true },
|
||||
{ name = "skip", type = "string", optional = true },
|
||||
{ name = "stopline", type = "number", optional = true },
|
||||
{ name = "timeout", type = "number", optional = true },
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
---@meta
|
||||
|
||||
---@alias blob number
|
||||
---@alias buffer integer
|
||||
---@alias channel integer
|
||||
---@alias float number
|
||||
---@alias job number
|
||||
---@alias object any
|
||||
---@alias sends number
|
||||
---@alias tabpage integer
|
||||
---@alias window integer
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,640 +0,0 @@
|
||||
---@meta
|
||||
|
||||
---
|
||||
---@meta
|
||||
---The definitions are developed in this repository: https://github.com/LuaCATS/lpeg
|
||||
|
||||
---
|
||||
---This type definition is based on the [HTML documentation](http://www.inf.puc-rio.br/~roberto/lpeg/) of the LPeg library. A different HTML documentation can be found at http://stevedonovan.github.io/lua-stdlibs/modules/lpeg.html.
|
||||
---
|
||||
---*LPeg* is a new pattern-matching library for Lua,
|
||||
---based on
|
||||
---[Parsing Expression Grammars](https://bford.info/packrat/) (PEGs).
|
||||
---This text is a reference manual for the library.
|
||||
---For a more formal treatment of LPeg,
|
||||
---as well as some discussion about its implementation,
|
||||
---see
|
||||
---[A Text Pattern-Matching Tool based on Parsing Expression Grammars](http://www.inf.puc-rio.br/~roberto/docs/peg.pdf).
|
||||
---(You may also be interested in my
|
||||
---[talk about LPeg](https://vimeo.com/1485123)
|
||||
---given at the III Lua Workshop.)
|
||||
---
|
||||
---Following the Snobol tradition,
|
||||
---LPeg defines patterns as first-class objects.
|
||||
---That is, patterns are regular Lua values
|
||||
---(represented by userdata).
|
||||
---The library offers several functions to create
|
||||
---and compose patterns.
|
||||
---With the use of metamethods,
|
||||
---several of these functions are provided as infix or prefix
|
||||
---operators.
|
||||
---On the one hand,
|
||||
---the result is usually much more verbose than the typical
|
||||
---encoding of patterns using the so called
|
||||
---*regular expressions*
|
||||
---(which typically are not regular expressions in the formal sense).
|
||||
---On the other hand,
|
||||
---first-class patterns allow much better documentation
|
||||
---(as it is easy to comment the code,
|
||||
---to break complex definitions in smaller parts, etc.)
|
||||
---and are extensible,
|
||||
---as we can define new functions to create and compose patterns.
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
local lpeg = {}
|
||||
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
---@class Pattern
|
||||
---@operator unm: Pattern
|
||||
---@operator add(Pattern): Pattern
|
||||
---@operator sub(Pattern): Pattern
|
||||
---@operator mul(Pattern): Pattern
|
||||
---@operator mul(Capture): Pattern
|
||||
---@operator div(string): Capture
|
||||
---@operator div(number): Capture
|
||||
---@operator div(table): Capture
|
||||
---@operator div(function): Capture
|
||||
---@operator pow(number): Pattern
|
||||
---@operator mod(function): nil
|
||||
local Pattern = {}
|
||||
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
---@alias Capture Pattern
|
||||
---@operator add(Capture): Pattern
|
||||
---@operator mul(Capture): Pattern
|
||||
---@operator mul(Pattern): Pattern
|
||||
---@operator div(string): Capture
|
||||
---@operator div(number): Capture
|
||||
---@operator div(table): Capture
|
||||
---@operator div(function): Capture
|
||||
---@operator pow(number): Pattern
|
||||
|
||||
---
|
||||
---Match the given `pattern` against the `subject` string.
|
||||
---
|
||||
---If the match succeeds,
|
||||
---returns the index in the subject of the first character after the match,
|
||||
---or the captured values
|
||||
---(if the pattern captured any value).
|
||||
---
|
||||
---An optional numeric argument `init` makes the match
|
||||
---start at that position in the subject string.
|
||||
---As usual in Lua libraries,
|
||||
---a negative value counts from the end.
|
||||
---
|
||||
---Unlike typical pattern-matching functions,
|
||||
---`match` works only in anchored mode;
|
||||
---that is, it tries to match the pattern with a prefix of
|
||||
---the given subject string (at position `init`),
|
||||
---not with an arbitrary substring of the subject.
|
||||
---So, if we want to find a pattern anywhere in a string,
|
||||
---we must either write a loop in Lua or write a pattern that
|
||||
---matches anywhere.
|
||||
---This second approach is easy and quite efficient;
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local pattern = lpeg.R('az') ^ 1 * -1
|
||||
---assert(pattern:match('hello') == 6)
|
||||
---assert(lpeg.match(pattern, 'hello') == 6)
|
||||
---assert(pattern:match('1 hello') == nil)
|
||||
---```
|
||||
---
|
||||
---@param pattern Pattern
|
||||
---@param subject string
|
||||
---@param init? integer
|
||||
---
|
||||
---@return any ...
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.match(pattern, subject, init) end
|
||||
|
||||
---
|
||||
---Match the given `pattern` against the `subject` string.
|
||||
---
|
||||
---If the match succeeds,
|
||||
---returns the index in the subject of the first character after the match,
|
||||
---or the captured values
|
||||
---(if the pattern captured any value).
|
||||
---
|
||||
---An optional numeric argument `init` makes the match
|
||||
---start at that position in the subject string.
|
||||
---As usual in Lua libraries,
|
||||
---a negative value counts from the end.
|
||||
---
|
||||
---Unlike typical pattern-matching functions,
|
||||
---`match` works only in anchored mode;
|
||||
---that is, it tries to match the pattern with a prefix of
|
||||
---the given subject string (at position `init`),
|
||||
---not with an arbitrary substring of the subject.
|
||||
---So, if we want to find a pattern anywhere in a string,
|
||||
---we must either write a loop in Lua or write a pattern that
|
||||
---matches anywhere.
|
||||
---This second approach is easy and quite efficient;
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local pattern = lpeg.R('az') ^ 1 * -1
|
||||
---assert(pattern:match('hello') == 6)
|
||||
---assert(lpeg.match(pattern, 'hello') == 6)
|
||||
---assert(pattern:match('1 hello') == nil)
|
||||
---```
|
||||
---
|
||||
---@param subject string
|
||||
---@param init? integer
|
||||
---
|
||||
---@return any ...
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function Pattern:match(subject, init) end
|
||||
|
||||
---
|
||||
---Return the string `"pattern"` if the given value is a pattern, otherwise `nil`.
|
||||
---
|
||||
---@return 'pattern'|nil
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.type(value) end
|
||||
|
||||
---
|
||||
---Return a string with the running version of LPeg.
|
||||
---
|
||||
---@return string
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.version() end
|
||||
|
||||
---
|
||||
---Set a limit for the size of the backtrack stack used by LPeg to
|
||||
---track calls and choices.
|
||||
---
|
||||
---The default limit is `400`.
|
||||
---Most well-written patterns need little backtrack levels and
|
||||
---therefore you seldom need to change this limit;
|
||||
---before changing it you should try to rewrite your
|
||||
---pattern to avoid the need for extra space.
|
||||
---Nevertheless, a few useful patterns may overflow.
|
||||
---Also, with recursive grammars,
|
||||
---subjects with deep recursion may also need larger limits.
|
||||
---
|
||||
---@param max integer
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.setmaxstack(max) end
|
||||
|
||||
---
|
||||
---Convert the given value into a proper pattern.
|
||||
---
|
||||
---The following rules are applied:
|
||||
---
|
||||
---* If the argument is a pattern,
|
||||
---it is returned unmodified.
|
||||
---
|
||||
---* If the argument is a string,
|
||||
---it is translated to a pattern that matches the string literally.
|
||||
---
|
||||
---* If the argument is a non-negative number `n`,
|
||||
---the result is a pattern that matches exactly `n` characters.
|
||||
---
|
||||
---* If the argument is a negative number `-n`,
|
||||
---the result is a pattern that
|
||||
---succeeds only if the input string has less than `n` characters left:
|
||||
---`lpeg.P(-n)`
|
||||
---is equivalent to `-lpeg.P(n)`
|
||||
---(see the unary minus operation).
|
||||
---
|
||||
---* If the argument is a boolean,
|
||||
---the result is a pattern that always succeeds or always fails
|
||||
---(according to the boolean value),
|
||||
---without consuming any input.
|
||||
---
|
||||
---* If the argument is a table,
|
||||
---it is interpreted as a grammar
|
||||
---(see Grammars).
|
||||
---
|
||||
---* If the argument is a function,
|
||||
---returns a pattern equivalent to a
|
||||
---match-time capture over the empty string.
|
||||
---
|
||||
---@param value Pattern|string|integer|boolean|table|function
|
||||
---
|
||||
---@return Pattern
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.P(value) end
|
||||
|
||||
---
|
||||
---Return a pattern that
|
||||
---matches only if the input string at the current position
|
||||
---is preceded by `patt`.
|
||||
---
|
||||
---Pattern `patt` must match only strings
|
||||
---with some fixed length,
|
||||
---and it cannot contain captures.
|
||||
---
|
||||
---Like the `and` predicate,
|
||||
---this pattern never consumes any input,
|
||||
---independently of success or failure.
|
||||
---
|
||||
---@param pattern Pattern|string|integer|boolean|table
|
||||
---
|
||||
---@return Pattern
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.B(pattern) end
|
||||
|
||||
---
|
||||
---Return a pattern that matches any single character
|
||||
---belonging to one of the given ranges.
|
||||
---
|
||||
---Each `range` is a string `xy` of length 2,
|
||||
---representing all characters with code
|
||||
---between the codes of `x` and `y`
|
||||
---(both inclusive).
|
||||
---
|
||||
---As an example, the pattern
|
||||
---`lpeg.R('09')` matches any digit,
|
||||
---and `lpeg.R('az', 'AZ')` matches any ASCII letter.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local pattern = lpeg.R('az') ^ 1 * -1
|
||||
---assert(pattern:match('hello') == 6)
|
||||
---```
|
||||
---
|
||||
---@param ... string
|
||||
---
|
||||
---@return Pattern
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.R(...) end
|
||||
|
||||
---
|
||||
---Return a pattern that matches any single character that
|
||||
---appears in the given string.
|
||||
---(The `S` stands for Set.)
|
||||
---
|
||||
---As an example, the pattern
|
||||
---`lpeg.S('+-*/')` matches any arithmetic operator.
|
||||
---
|
||||
---Note that, if `s` is a character
|
||||
---(that is, a string of length 1),
|
||||
---then `lpeg.P(s)` is equivalent to `lpeg.S(s)`
|
||||
---which is equivalent to `lpeg.R(s..s)`.
|
||||
---Note also that both `lpeg.S('')` and `lpeg.R()`
|
||||
---are patterns that always fail.
|
||||
---
|
||||
---@param string string
|
||||
---
|
||||
---@return Pattern
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.S(string) end
|
||||
|
||||
---
|
||||
---Create a non-terminal (a variable) for a grammar.
|
||||
---
|
||||
---This operation creates a non-terminal (a variable)
|
||||
---for a grammar.
|
||||
---The created non-terminal refers to the rule indexed by `v`
|
||||
---in the enclosing grammar.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local b = lpeg.P({'(' * ((1 - lpeg.S '()') + lpeg.V(1)) ^ 0 * ')'})
|
||||
---assert(b:match('((string))') == 11)
|
||||
---assert(b:match('(') == nil)
|
||||
---```
|
||||
---
|
||||
---@param v string|integer
|
||||
---
|
||||
---@return Pattern
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.V(v) end
|
||||
|
||||
---
|
||||
---@class Locale
|
||||
---@field alnum userdata
|
||||
---@field alpha userdata
|
||||
---@field cntrl userdata
|
||||
---@field digit userdata
|
||||
---@field graph userdata
|
||||
---@field lower userdata
|
||||
---@field print userdata
|
||||
---@field punct userdata
|
||||
---@field space userdata
|
||||
---@field upper userdata
|
||||
---@field xdigit userdata
|
||||
|
||||
---
|
||||
---Return a table with patterns for matching some character classes
|
||||
---according to the current locale.
|
||||
---
|
||||
---The table has fields named
|
||||
---`alnum`,
|
||||
---`alpha`,
|
||||
---`cntrl`,
|
||||
---`digit`,
|
||||
---`graph`,
|
||||
---`lower`,
|
||||
---`print`,
|
||||
---`punct`,
|
||||
---`space`,
|
||||
---`upper`, and
|
||||
---`xdigit`,
|
||||
---each one containing a correspondent pattern.
|
||||
---Each pattern matches any single character that belongs to its class.
|
||||
--
|
||||
---If called with an argument `table`,
|
||||
---then it creates those fields inside the given table and
|
||||
---returns that table.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---lpeg.locale(lpeg)
|
||||
---local space = lpeg.space ^ 0
|
||||
---local name = lpeg.C(lpeg.alpha ^ 1) * space
|
||||
---local sep = lpeg.S(',;') * space
|
||||
---local pair = lpeg.Cg(name * '=' * space * name) * sep ^ -1
|
||||
---local list = lpeg.Cf(lpeg.Ct('') * pair ^ 0, rawset)
|
||||
---local t = list:match('a=b, c = hi; next = pi')
|
||||
---assert(t.a == 'b')
|
||||
---assert(t.c == 'hi')
|
||||
---assert(t.next == 'pi')
|
||||
---
|
||||
---local locale = lpeg.locale()
|
||||
---assert(type(locale.digit) == 'userdata')
|
||||
---```
|
||||
---
|
||||
---@param tab? table
|
||||
---
|
||||
---@return Locale
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.locale(tab) end
|
||||
|
||||
---
|
||||
---Create a simple capture.
|
||||
---
|
||||
---Creates a simple capture,
|
||||
---which captures the substring of the subject that matches `patt`.
|
||||
---The captured value is a string.
|
||||
---If `patt` has other captures,
|
||||
---their values are returned after this one.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local function split (s, sep)
|
||||
--- sep = lpeg.P(sep)
|
||||
--- local elem = lpeg.C((1 - sep) ^ 0)
|
||||
--- local p = elem * (sep * elem) ^ 0
|
||||
--- return lpeg.match(p, s)
|
||||
---end
|
||||
---
|
||||
---local a, b, c = split('a,b,c', ',')
|
||||
---assert(a == 'a')
|
||||
---assert(b == 'b')
|
||||
---assert(c == 'c')
|
||||
---```
|
||||
---
|
||||
---@param patt Pattern|string|integer|boolean|table|function
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.C(patt) end
|
||||
|
||||
---
|
||||
---Create an argument capture.
|
||||
---
|
||||
---This pattern matches the empty string and
|
||||
---produces the value given as the nth extra
|
||||
---argument given in the call to `lpeg.match`.
|
||||
---
|
||||
---@param n integer
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Carg(n) end
|
||||
|
||||
---
|
||||
---Create a back capture.
|
||||
---
|
||||
---This pattern matches the empty string and
|
||||
---produces the values produced by the most recent
|
||||
---group capture named `name`
|
||||
---(where `name` can be any Lua value).
|
||||
---
|
||||
---Most recent means the last
|
||||
---complete
|
||||
---outermost
|
||||
---group capture with the given name.
|
||||
---A Complete capture means that the entire pattern
|
||||
---corresponding to the capture has matched.
|
||||
---An Outermost capture means that the capture is not inside
|
||||
---another complete capture.
|
||||
---
|
||||
---In the same way that LPeg does not specify when it evaluates captures,
|
||||
---it does not specify whether it reuses
|
||||
---values previously produced by the group
|
||||
---or re-evaluates them.
|
||||
---
|
||||
---@param name any
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cb(name) end
|
||||
|
||||
---
|
||||
---Create a constant capture.
|
||||
---
|
||||
---This pattern matches the empty string and
|
||||
---produces all given values as its captured values.
|
||||
---
|
||||
---@param ... any
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cc(...) end
|
||||
|
||||
---
|
||||
---Create a fold capture.
|
||||
---
|
||||
---If `patt` produces a list of captures
|
||||
---C1 C2 ... Cn,
|
||||
---this capture will produce the value
|
||||
---`func(...func(func(C1, C2), C3)...,Cn)`,
|
||||
---that is, it will fold
|
||||
---(or accumulate, or reduce)
|
||||
---the captures from `patt` using function `func`.
|
||||
---
|
||||
---This capture assumes that `patt` should produce
|
||||
---at least one capture with at least one value (of any type),
|
||||
---which becomes the initial value of an accumulator.
|
||||
---(If you need a specific initial value,
|
||||
---you may prefix a constant capture to `patt`.)
|
||||
---For each subsequent capture,
|
||||
---LPeg calls `func`
|
||||
---with this accumulator as the first argument and all values produced
|
||||
---by the capture as extra arguments;
|
||||
---the first result from this call
|
||||
---becomes the new value for the accumulator.
|
||||
---The final value of the accumulator becomes the captured value.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local number = lpeg.R('09') ^ 1 / tonumber
|
||||
---local list = number * (',' * number) ^ 0
|
||||
---local function add(acc, newvalue) return acc + newvalue end
|
||||
---local sum = lpeg.Cf(list, add)
|
||||
---assert(sum:match('10,30,43') == 83)
|
||||
---```
|
||||
---
|
||||
---@param patt Pattern|string|number|boolean|table|function
|
||||
---@param func fun(acc, newvalue): (acc: any)
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cf(patt, func) end
|
||||
|
||||
---
|
||||
---Create a group capture.
|
||||
---
|
||||
---It groups all values returned by `patt`
|
||||
---into a single capture.
|
||||
---The group may be anonymous (if no name is given)
|
||||
---or named with the given name
|
||||
---(which can be any non-nil Lua value).
|
||||
---
|
||||
---@param patt Pattern|string|number|boolean|table|function
|
||||
---@param name? string
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cg(patt, name) end
|
||||
|
||||
---
|
||||
---Create a position capture.
|
||||
---
|
||||
---It matches the empty string and
|
||||
---captures the position in the subject where the match occurs.
|
||||
---The captured value is a number.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local I = lpeg.Cp()
|
||||
---local function anywhere(p) return lpeg.P({I * p * I + 1 * lpeg.V(1)}) end
|
||||
---
|
||||
---local match_start, match_end = anywhere('world'):match('hello world!')
|
||||
---assert(match_start == 7)
|
||||
---assert(match_end == 12)
|
||||
---```
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cp() end
|
||||
|
||||
---
|
||||
---Create a substitution capture.
|
||||
---
|
||||
---This function creates a substitution capture,
|
||||
---which captures the substring of the subject that matches `patt`,
|
||||
---with substitutions.
|
||||
---For any capture inside `patt` with a value,
|
||||
---the substring that matched the capture is replaced by the capture value
|
||||
---(which should be a string).
|
||||
---The final captured value is the string resulting from
|
||||
---all replacements.
|
||||
---
|
||||
---__Example:__
|
||||
---
|
||||
---```lua
|
||||
---local function gsub (s, patt, repl)
|
||||
--- patt = lpeg.P(patt)
|
||||
--- patt = lpeg.Cs((patt / repl + 1) ^ 0)
|
||||
--- return lpeg.match(patt, s)
|
||||
---end
|
||||
---assert(gsub('Hello, xxx!', 'xxx', 'World') == 'Hello, World!')
|
||||
---```
|
||||
---
|
||||
---@param patt Pattern|string|number|boolean|table|function
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cs(patt) end
|
||||
|
||||
---
|
||||
---Create a table capture.
|
||||
---
|
||||
---This capture returns a table with all values from all anonymous captures
|
||||
---made by `patt` inside this table in successive integer keys,
|
||||
---starting at 1.
|
||||
---Moreover,
|
||||
---for each named capture group created by `patt`,
|
||||
---the first value of the group is put into the table
|
||||
---with the group name as its key.
|
||||
---The captured value is only the table.
|
||||
---
|
||||
---@param patt Pattern|string|number|boolean|table|function
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Ct(patt) end
|
||||
|
||||
---
|
||||
---Create a match-time capture.
|
||||
---
|
||||
---Unlike all other captures,
|
||||
---this one is evaluated immediately when a match occurs
|
||||
---(even if it is part of a larger pattern that fails later).
|
||||
---It forces the immediate evaluation of all its nested captures
|
||||
---and then calls `function`.
|
||||
---
|
||||
---The given function gets as arguments the entire subject,
|
||||
---the current position (after the match of `patt`),
|
||||
---plus any capture values produced by `patt`.
|
||||
---
|
||||
---The first value returned by `fn`
|
||||
---defines how the match happens.
|
||||
---If the call returns a number,
|
||||
---the match succeeds
|
||||
---and the returned number becomes the new current position.
|
||||
---(Assuming a subject and current position `i`,
|
||||
---the returned number must be in the range `[i, len(s) + 1]`.)
|
||||
---If the call returns true,
|
||||
---the match succeeds without consuming any input.
|
||||
---(So, to return true is equivalent to return `i`.)
|
||||
---If the call returns `false`, `nil`, or no value,
|
||||
---the match fails.
|
||||
---
|
||||
---Any extra values returned by the function become the
|
||||
---values produced by the capture.
|
||||
---
|
||||
---@param patt Pattern|string|number|boolean|table|function
|
||||
---@param fn fun(s: string, i: integer, ...: any): (position: boolean|number, ...: any)
|
||||
---
|
||||
---@return Capture
|
||||
---
|
||||
---😱 [Types](https://github.com/LuaCATS/lpeg/blob/main/library/lpeg.lua) incomplete or incorrect? 🙏 [Please contribute!](https://github.com/LuaCATS/lpeg/pulls)
|
||||
function lpeg.Cmt(patt, fn) end
|
||||
|
||||
return lpeg
|
||||
@ -1,310 +0,0 @@
|
||||
---@meta
|
||||
|
||||
|
||||
|
||||
-- Invokes |vim-function| or |user-function| {func} with arguments {...}.
|
||||
-- See also |vim.fn|.
|
||||
-- Equivalent to:
|
||||
-- ```lua
|
||||
-- vim.fn[func]({...})
|
||||
-- ```
|
||||
--- @param func fun()
|
||||
function vim.call(func, ...) end
|
||||
|
||||
-- Run diff on strings {a} and {b}. Any indices returned by this function,
|
||||
-- either directly or via callback arguments, are 1-based.
|
||||
--
|
||||
-- Examples:
|
||||
-- ```lua
|
||||
-- vim.diff('a\n', 'b\nc\n')
|
||||
-- -- =>
|
||||
-- -- @@ -1 +1,2 @@
|
||||
-- -- -a
|
||||
-- -- +b
|
||||
-- -- +c
|
||||
--
|
||||
-- vim.diff('a\n', 'b\nc\n', {result_type = 'indices'})
|
||||
-- -- =>
|
||||
-- -- {
|
||||
-- -- {1, 1, 1, 2}
|
||||
-- -- }
|
||||
-- ```
|
||||
-- Parameters: ~
|
||||
-- • {a} First string to compare
|
||||
-- • {b} Second string to compare
|
||||
-- • {opts} Optional parameters:
|
||||
-- • `on_hunk` (callback):
|
||||
-- Invoked for each hunk in the diff. Return a negative number
|
||||
-- to cancel the callback for any remaining hunks.
|
||||
-- Args:
|
||||
-- • `start_a` (integer): Start line of hunk in {a}.
|
||||
-- • `count_a` (integer): Hunk size in {a}.
|
||||
-- • `start_b` (integer): Start line of hunk in {b}.
|
||||
-- • `count_b` (integer): Hunk size in {b}.
|
||||
-- • `result_type` (string): Form of the returned diff:
|
||||
-- • "unified": (default) String in unified format.
|
||||
-- • "indices": Array of hunk locations.
|
||||
-- Note: This option is ignored if `on_hunk` is used.
|
||||
-- • `linematch` (boolean|integer): Run linematch on the resulting hunks
|
||||
-- from xdiff. When integer, only hunks upto this size in
|
||||
-- lines are run through linematch. Requires `result_type = indices`,
|
||||
-- ignored otherwise.
|
||||
-- • `algorithm` (string):
|
||||
-- Diff algorithm to use. Values:
|
||||
-- • "myers" the default algorithm
|
||||
-- • "minimal" spend extra time to generate the
|
||||
-- smallest possible diff
|
||||
-- • "patience" patience diff algorithm
|
||||
-- • "histogram" histogram diff algorithm
|
||||
-- • `ctxlen` (integer): Context length
|
||||
-- • `interhunkctxlen` (integer):
|
||||
-- Inter hunk context length
|
||||
-- • `ignore_whitespace` (boolean):
|
||||
-- Ignore whitespace
|
||||
-- • `ignore_whitespace_change` (boolean):
|
||||
-- Ignore whitespace change
|
||||
-- • `ignore_whitespace_change_at_eol` (boolean)
|
||||
-- Ignore whitespace change at end-of-line.
|
||||
-- • `ignore_cr_at_eol` (boolean)
|
||||
-- Ignore carriage return at end-of-line
|
||||
-- • `ignore_blank_lines` (boolean)
|
||||
-- Ignore blank lines
|
||||
-- • `indent_heuristic` (boolean):
|
||||
-- Use the indent heuristic for the internal
|
||||
-- diff library.
|
||||
--
|
||||
-- Return: ~
|
||||
-- See {opts.result_type}. nil if {opts.on_hunk} is given.
|
||||
--- @param opts table<string, any>
|
||||
function vim.diff(a, b, opts) end
|
||||
|
||||
-- The result is a String, which is the text {str} converted from
|
||||
-- encoding {from} to encoding {to}. When the conversion fails `nil` is
|
||||
-- returned. When some characters could not be converted they
|
||||
-- are replaced with "?".
|
||||
-- The encoding names are whatever the iconv() library function
|
||||
-- can accept, see ":Man 3 iconv".
|
||||
--
|
||||
-- Parameters: ~
|
||||
-- • {str} (string) Text to convert
|
||||
-- • {from} (string) Encoding of {str}
|
||||
-- • {to} (string) Target encoding
|
||||
--
|
||||
-- Returns: ~
|
||||
-- Converted string if conversion succeeds, `nil` otherwise.
|
||||
--- @param str string
|
||||
--- @param from number
|
||||
--- @param to number
|
||||
--- @param opts? table<string, any>
|
||||
function vim.iconv(str, from, to, opts) end
|
||||
|
||||
-- Returns true if the code is executing as part of a "fast" event handler,
|
||||
-- where most of the API is disabled. These are low-level events (e.g.
|
||||
-- |lua-loop-callbacks|) which can be invoked whenever Nvim polls for input.
|
||||
-- When this is `false` most API functions are callable (but may be subject
|
||||
-- to other restrictions such as |textlock|).
|
||||
function vim.in_fast_event() end
|
||||
|
||||
-- Decodes (or "unpacks") the JSON-encoded {str} to a Lua object.
|
||||
--
|
||||
-- {opts} is a table with the key `luanil = { object: bool, array: bool }`
|
||||
-- that controls whether `null` in JSON objects or arrays should be converted
|
||||
-- to Lua `nil` instead of `vim.NIL`.
|
||||
--- @param str string
|
||||
--- @param opts? table<string, any>
|
||||
function vim.json.decode(str, opts) end
|
||||
|
||||
-- Encodes (or "packs") Lua object {obj} as JSON in a Lua string.
|
||||
function vim.json.encode(obj) end
|
||||
|
||||
-- Decodes (or "unpacks") the msgpack-encoded {str} to a Lua object.
|
||||
--- @param str string
|
||||
function vim.mpack.decode(str) end
|
||||
|
||||
-- Encodes (or "packs") Lua object {obj} as msgpack in a Lua string.
|
||||
function vim.mpack.encode(obj) end
|
||||
|
||||
-- Parse the Vim regex {re} and return a regex object. Regexes are "magic"
|
||||
-- and case-sensitive by default, regardless of 'magic' and 'ignorecase'.
|
||||
-- They can be controlled with flags, see |/magic| and |/ignorecase|.
|
||||
function vim.regex(re) end
|
||||
|
||||
-- Sends {event} to {channel} via |RPC| and returns immediately. If {channel}
|
||||
-- is 0, the event is broadcast to all channels.
|
||||
--
|
||||
-- This function also works in a fast callback |lua-loop-callbacks|.
|
||||
--- @param args? any[]
|
||||
--- @param ...? any
|
||||
function vim.rpcnotify(channel, method, args, ...) end
|
||||
|
||||
-- Sends a request to {channel} to invoke {method} via |RPC| and blocks until
|
||||
-- a response is received.
|
||||
--
|
||||
-- Note: NIL values as part of the return value is represented as |vim.NIL|
|
||||
-- special value
|
||||
--- @param args? any[]
|
||||
--- @param ...? any
|
||||
function vim.rpcrequest(channel, method, args, ...) end
|
||||
|
||||
-- Schedules {callback} to be invoked soon by the main event-loop. Useful
|
||||
-- to avoid |textlock| or other temporary restrictions.
|
||||
--- @param callback fun()
|
||||
function vim.schedule(callback) end
|
||||
|
||||
-- Check {str} for spelling errors. Similar to the Vimscript function
|
||||
-- |spellbadword()|.
|
||||
--
|
||||
-- Note: The behaviour of this function is dependent on: 'spelllang',
|
||||
-- 'spellfile', 'spellcapcheck' and 'spelloptions' which can all be local to
|
||||
-- the buffer. Consider calling this with |nvim_buf_call()|.
|
||||
--
|
||||
-- Example:
|
||||
-- ```lua
|
||||
-- vim.spell.check("the quik brown fox")
|
||||
-- -- =>
|
||||
-- -- {
|
||||
-- -- {'quik', 'bad', 5}
|
||||
-- -- }
|
||||
-- ```
|
||||
-- Parameters: ~
|
||||
-- • {str} String to spell check.
|
||||
--
|
||||
-- Return: ~
|
||||
-- List of tuples with three items:
|
||||
-- - The badly spelled word.
|
||||
-- - The type of the spelling error:
|
||||
-- "bad" spelling mistake
|
||||
-- "rare" rare word
|
||||
-- "local" word only valid in another region
|
||||
-- "caps" word should start with Capital
|
||||
-- - The position in {str} where the word begins.
|
||||
--- @param str string
|
||||
function vim.spell.check(str) end
|
||||
|
||||
-- Convert UTF-32 or UTF-16 {index} to byte index. If {use_utf16} is not
|
||||
-- supplied, it defaults to false (use UTF-32). Returns the byte index.
|
||||
--
|
||||
-- Invalid UTF-8 and NUL is treated like by |vim.str_byteindex()|.
|
||||
-- An {index} in the middle of a UTF-16 sequence is rounded upwards to
|
||||
-- the end of that sequence.
|
||||
--- @param str string
|
||||
--- @param index number
|
||||
--- @param use_utf16? any
|
||||
function vim.str_byteindex(str, index, use_utf16) end
|
||||
|
||||
-- Convert byte index to UTF-32 and UTF-16 indices. If {index} is not
|
||||
-- supplied, the length of the string is used. All indices are zero-based.
|
||||
-- Returns two values: the UTF-32 and UTF-16 indices respectively.
|
||||
--
|
||||
-- Embedded NUL bytes are treated as terminating the string. Invalid UTF-8
|
||||
-- bytes, and embedded surrogates are counted as one code point each. An
|
||||
-- {index} in the middle of a UTF-8 sequence is rounded upwards to the end of
|
||||
-- that sequence.
|
||||
--- @param str string
|
||||
--- @param index? number
|
||||
function vim.str_utfindex(str, index) end
|
||||
|
||||
-- Compares strings case-insensitively. Returns 0, 1 or -1 if strings are
|
||||
-- equal, {a} is greater than {b} or {a} is lesser than {b}, respectively.
|
||||
function vim.stricmp(a, b) end
|
||||
|
||||
-- Attach to ui events, similar to |nvim_ui_attach()| but receive events
|
||||
-- as lua callback. Can be used to implement screen elements like
|
||||
-- popupmenu or message handling in lua.
|
||||
--
|
||||
-- {options} should be a dictionary-like table, where `ext_...` options should
|
||||
-- be set to true to receive events for the respective external element.
|
||||
--
|
||||
-- {callback} receives event name plus additional parameters. See |ui-popupmenu|
|
||||
-- and the sections below for event format for respective events.
|
||||
--
|
||||
-- WARNING: This api is considered experimental. Usability will vary for
|
||||
-- different screen elements. In particular `ext_messages` behavior is subject
|
||||
-- to further changes and usability improvements. This is expected to be
|
||||
-- used to handle messages when setting 'cmdheight' to zero (which is
|
||||
-- likewise experimental).
|
||||
--
|
||||
-- Example (stub for a |ui-popupmenu| implementation):
|
||||
-- ```lua
|
||||
--
|
||||
-- ns = vim.api.nvim_create_namespace('my_fancy_pum')
|
||||
--
|
||||
-- vim.ui_attach(ns, {ext_popupmenu=true}, function(event, ...)
|
||||
-- if event == "popupmenu_show" then
|
||||
-- local items, selected, row, col, grid = ...
|
||||
-- print("display pum ", #items)
|
||||
-- elseif event == "popupmenu_select" then
|
||||
-- local selected = ...
|
||||
-- print("selected", selected)
|
||||
-- elseif event == "popupmenu_hide" then
|
||||
-- print("FIN")
|
||||
-- end
|
||||
-- end)
|
||||
-- ```
|
||||
--- @param ns number
|
||||
--- @param options table<string, any>
|
||||
--- @param callback fun()
|
||||
function vim.ui_attach(ns, options, callback) end
|
||||
|
||||
-- Detach a callback previously attached with |vim.ui_attach()| for the
|
||||
-- given namespace {ns}.
|
||||
--- @param ns number
|
||||
function vim.ui_detach(ns) end
|
||||
|
||||
-- Wait for {time} in milliseconds until {callback} returns `true`.
|
||||
--
|
||||
-- Executes {callback} immediately and at approximately {interval}
|
||||
-- milliseconds (default 200). Nvim still processes other events during
|
||||
-- this time.
|
||||
--
|
||||
-- Parameters: ~
|
||||
-- • {time} Number of milliseconds to wait
|
||||
-- • {callback} Optional callback. Waits until {callback} returns true
|
||||
-- • {interval} (Approximate) number of milliseconds to wait between polls
|
||||
-- • {fast_only} If true, only |api-fast| events will be processed.
|
||||
-- If called from while in an |api-fast| event, will
|
||||
-- automatically be set to `true`.
|
||||
--
|
||||
-- Returns: ~
|
||||
-- If {callback} returns `true` during the {time}:
|
||||
-- `true, nil`
|
||||
--
|
||||
-- If {callback} never returns `true` during the {time}:
|
||||
-- `false, -1`
|
||||
--
|
||||
-- If {callback} is interrupted during the {time}:
|
||||
-- `false, -2`
|
||||
--
|
||||
-- If {callback} errors, the error is raised.
|
||||
--
|
||||
-- Examples:
|
||||
-- ```lua
|
||||
--
|
||||
-- ---
|
||||
-- -- Wait for 100 ms, allowing other events to process
|
||||
-- vim.wait(100, function() end)
|
||||
--
|
||||
-- ---
|
||||
-- -- Wait for 100 ms or until global variable set.
|
||||
-- vim.wait(100, function() return vim.g.waiting_for_var end)
|
||||
--
|
||||
-- ---
|
||||
-- -- Wait for 1 second or until global variable set, checking every ~500 ms
|
||||
-- vim.wait(1000, function() return vim.g.waiting_for_var end, 500)
|
||||
--
|
||||
-- ---
|
||||
-- -- Schedule a function to set a value in 100ms
|
||||
-- vim.defer_fn(function() vim.g.timer_result = true end, 100)
|
||||
--
|
||||
-- -- Would wait ten seconds if results blocked. Actually only waits 100 ms
|
||||
-- if vim.wait(10000, function() return vim.g.timer_result end) then
|
||||
-- print('Only waiting a little bit of time!')
|
||||
-- end
|
||||
-- ```
|
||||
--- @param time number
|
||||
--- @param condition? fun(): boolean
|
||||
--- @param interval? number
|
||||
--- @param fast_only? boolean
|
||||
--- @return boolean, nil|number
|
||||
function vim.wait(time, condition, interval, fast_only) end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,40 +0,0 @@
|
||||
---@meta
|
||||
|
||||
vim = {}
|
||||
|
||||
---@type uv
|
||||
vim.loop = {}
|
||||
|
||||
vim.F = require("vim.F")
|
||||
vim.diagnostic = require("vim.diagnostic")
|
||||
vim.filetype = require("vim.filetype")
|
||||
vim.fs = require("vim.fs")
|
||||
vim.health = require("vim.health")
|
||||
vim.highlight = require("vim.highlight")
|
||||
vim.inspect = require("vim.inspect").inspect
|
||||
vim.iter = require("vim.iter")
|
||||
vim.keymap = require("vim.keymap")
|
||||
vim.lsp = require("vim.lsp")
|
||||
vim.secure = require("vim.secure")
|
||||
vim.treesitter = require("vim.treesitter")
|
||||
vim.treesitter.highlighter = require("vim.treesitter.highlighter")
|
||||
vim.treesitter.language = require("vim.treesitter.language")
|
||||
vim.treesitter.query = require("vim.treesitter.query")
|
||||
vim.ui = require("vim.ui")
|
||||
vim.uri_from_bufnr = require("vim.uri").uri_from_bufnr
|
||||
vim.uri_from_fname = require("vim.uri").uri_from_fname
|
||||
vim.uri_to_bufnr = require("vim.uri").uri_to_bufnr
|
||||
vim.uri_to_fname = require("vim.uri").uri_to_fname
|
||||
vim.version = require("vim.version")
|
||||
vim.lpeg = require("lpeg")
|
||||
|
||||
---@type table<string,any>
|
||||
vim.g = {}
|
||||
---@type table<string,any>
|
||||
vim.v = {}
|
||||
---@type table<number,table<string, any>>
|
||||
vim.b = {}
|
||||
---@type table<number,table<string, any>>
|
||||
vim.w = {}
|
||||
---@type table<number,table<string, any>>
|
||||
vim.t = {}
|
||||
@ -1,2 +0,0 @@
|
||||
[vim]
|
||||
any = true
|
||||
@ -1 +0,0 @@
|
||||
github: norcalli
|
||||
@ -1,34 +0,0 @@
|
||||
---
|
||||
name: Bug
|
||||
about: Create a bug report
|
||||
title: 'Bug:'
|
||||
labels: bug
|
||||
assignees: akianonymus
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Your configuration and/or a small reproducible test, and/or the steps required to reproduce.
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Operating System:**
|
||||
e.g. Ubuntu 16.04
|
||||
|
||||
**Neovim Version:**
|
||||
e.g. 0.4.2
|
||||
|
||||
**Colorizer Version:**
|
||||
Paste the output of
|
||||
|
||||
`find ~/.config/nvim/ -type d -name 'nvim-colorizer.lua' -exec git rev-parse HEAD \;`
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@ -1,42 +0,0 @@
|
||||
# Simple workflow for deploying static content to GitHub Pages
|
||||
name: Deploy static content to Pages
|
||||
|
||||
on:
|
||||
# Runs on pushes targeting the default branch
|
||||
push:
|
||||
branches: ["master"]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
||||
permissions:
|
||||
contents: read
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
# Allow one concurrent deployment
|
||||
concurrency:
|
||||
group: "pages"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
# Single deploy job since we're just deploying
|
||||
deploy:
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Setup Pages
|
||||
uses: actions/configure-pages@v2
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-pages-artifact@v1
|
||||
with:
|
||||
# Upload entire repository
|
||||
path: 'doc'
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v1
|
||||
@ -1 +0,0 @@
|
||||
doc/tags
|
||||
@ -1,6 +0,0 @@
|
||||
column_width = 120
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferDouble"
|
||||
call_parentheses = "None"
|
||||
@ -1,16 +0,0 @@
|
||||
nvim-colorizer.lua is the fastest colorizer for neovim
|
||||
Copyright © 2019 Ashkan Kiani
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@ -1,250 +0,0 @@
|
||||
# colorizer.lua
|
||||
|
||||
[](https://nvchad.com/nvim-colorizer.lua/)
|
||||
|
||||
A high-performance color highlighter for Neovim which has **no external dependencies**! Written in performant Luajit.
|
||||
|
||||

|
||||
|
||||
## Installation and Usage
|
||||
|
||||
Requires Neovim >= 0.7.0 and `set termguicolors`.
|
||||
If you don't have true color for your terminal or are
|
||||
unsure, [read this excellent guide](https://github.com/termstandard/colors).
|
||||
|
||||
Use your plugin manager or clone directly into your package.
|
||||
|
||||
```lua
|
||||
use 'NvChad/nvim-colorizer.lua'
|
||||
```
|
||||
|
||||
As long as you have `malloc()` and `free()` on your system, this will work.
|
||||
Which includes Linux, OSX, and Windows.
|
||||
|
||||
One line setup. This will create an `autocmd` for `FileType *` to highlight
|
||||
every filetype.
|
||||
|
||||
**NOTE**: You should add this line after/below where your plugins are setup.
|
||||
|
||||
```lua
|
||||
require 'colorizer'.setup()
|
||||
```
|
||||
|
||||
### Use with commands
|
||||
|
||||
| Command | Description |
|
||||
|---|---|
|
||||
| **ColorizerAttachToBuffer** | Attach to the current buffer with given or default settings |
|
||||
| **ColorizerDetachFromBuffer** | Stop highlighting the current buffer |
|
||||
| **ColorizerReloadAllBuffers** | Reload all buffers that are being highlighted currently |
|
||||
| **ColorizerToggle** | Toggle highlighting of the current buffer |
|
||||
|
||||
### Use from lua
|
||||
|
||||
```lua
|
||||
|
||||
-- All options that can be passed to `user_default_options` in setup() can be passed here
|
||||
-- Similar for other functions
|
||||
|
||||
-- Attach to buffer
|
||||
require("colorizer").attach_to_buffer(0, { mode = "background", css = true})
|
||||
|
||||
-- Detach from buffer
|
||||
require("colorizer").detach_from_buffer(0, { mode = "virtualtext", css = true})
|
||||
|
||||
```
|
||||
## Why another highlighter?
|
||||
|
||||
Mostly, **RAW SPEED**.
|
||||
|
||||
This has no external dependencies, which means you install it and **it just
|
||||
works**. Other colorizers typically were synchronous and slow, as well. Being
|
||||
written with performance in mind and leveraging the excellent LuaJIT and a
|
||||
handwritten parser, updates can be done in real time. There are plugins such as
|
||||
[hexokinase](https://github.com/RRethy/vim-hexokinase) which have good
|
||||
performance, but it has some difficulty with becoming out of sync. The downside
|
||||
is that _this only works for Neovim_, and that will never change.
|
||||
|
||||
Apart from that, it only applies the highlights to the current visible contents, so
|
||||
even if a big file is opened, the editor won't just choke on a blank screen.
|
||||
|
||||
This idea was copied from
|
||||
[brenoprata10/nvim-highlight-colors](https://github.com/brenoprata10/nvim-highlight-colors)
|
||||
Credits to [brenoprata10](https://github.com/brenoprata10)
|
||||
|
||||
Additionally, having a Lua API that's available means users can use this as a
|
||||
library to do custom highlighting themselves.
|
||||
|
||||
## Customization
|
||||
|
||||
**Note**: These are the default options
|
||||
|
||||
```lua
|
||||
require("colorizer").setup {
|
||||
filetypes = { "*" },
|
||||
user_default_options = {
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
names = true, -- "Name" codes like Blue or blue
|
||||
RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||
AARRGGBB = false, -- 0xAARRGGBB hex codes
|
||||
rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
-- Available modes for `mode`: foreground, background, virtualtext
|
||||
mode = "background", -- Set the display mode.
|
||||
-- Available methods are false / true / "normal" / "lsp" / "both"
|
||||
-- True is same as normal
|
||||
tailwind = false, -- Enable tailwind colors
|
||||
-- parsers can contain values used in |user_default_options|
|
||||
sass = { enable = false, parsers = { "css" }, }, -- Enable sass colors
|
||||
virtualtext = "■",
|
||||
-- update color values even if buffer is not focused
|
||||
-- example use: cmp_menu, cmp_docs
|
||||
always_update = false
|
||||
},
|
||||
-- all the sub-options of filetypes apply to buftypes
|
||||
buftypes = {},
|
||||
}
|
||||
```
|
||||
|
||||
MODES:
|
||||
|
||||
- `foreground`: sets the foreground text color.
|
||||
- `background`: sets the background text color.
|
||||
- `virtualtext`: indicate the color behind the virtualtext.
|
||||
|
||||
For basic setup, you can use a command like the following.
|
||||
|
||||
```lua
|
||||
-- Attaches to every FileType mode
|
||||
require 'colorizer'.setup()
|
||||
|
||||
-- Attach to certain Filetypes, add special configuration for `html`
|
||||
-- Use `background` for everything else.
|
||||
require 'colorizer'.setup {
|
||||
filetypes = {
|
||||
'css',
|
||||
'javascript',
|
||||
html = { mode = 'foreground'; }
|
||||
},
|
||||
}
|
||||
|
||||
-- Use the `default_options` as the second parameter, which uses
|
||||
-- `foreground` for every mode. This is the inverse of the previous
|
||||
-- setup configuration.
|
||||
require 'colorizer'.setup {
|
||||
filetypes = {
|
||||
'css',
|
||||
'javascript',
|
||||
html = { mode = 'foreground'; }
|
||||
},
|
||||
user_default_options = { mode = "background", },
|
||||
}
|
||||
|
||||
-- Use the `default_options` as the second parameter, which uses
|
||||
-- `foreground` for every mode. This is the inverse of the previous
|
||||
-- setup configuration.
|
||||
require 'colorizer'.setup {
|
||||
filetypes = {
|
||||
'*'; -- Highlight all files, but customize some others.
|
||||
css = { rgb_fn = true; }; -- Enable parsing rgb(...) functions in css.
|
||||
html = { names = false; } -- Disable parsing "names" like Blue or Gray
|
||||
},
|
||||
}
|
||||
|
||||
-- Exclude some filetypes from highlighting by using `!`
|
||||
require 'colorizer'.setup {
|
||||
filetypes = {
|
||||
'*'; -- Highlight all files, but customize some others.
|
||||
'!vim'; -- Exclude vim from highlighting.
|
||||
-- Exclusion Only makes sense if '*' is specified!
|
||||
},
|
||||
}
|
||||
|
||||
-- Alwyas update the color values in cmp_docs even if it not focused
|
||||
require 'colorizer'.setup {
|
||||
filetypes = {
|
||||
'*'; -- Highlight all files, but customize some others.
|
||||
cmp_docs = {always_update = true}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
In `user_default_options`, there are 2 types of options
|
||||
|
||||
1. Individual options - `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` , `RRGGBBAA`, `AARRGGBB`, `tailwind`, `sass`
|
||||
|
||||
1. Alias options - `css`, `css_fn`
|
||||
|
||||
If `css_fn` is true, then `hsl_fn`, `rgb_fn` becomes `true`
|
||||
|
||||
If `css` is true, then `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` becomes `true`
|
||||
|
||||
These options have a priority, Individual options have the highest priority, then alias options
|
||||
|
||||
For alias, `css_fn` has more priority over `css`
|
||||
|
||||
e.g: Here `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` is enabled but not `names`
|
||||
|
||||
```lua
|
||||
require 'colorizer'.setup { user_default_options = { names = false, css = true } }
|
||||
```
|
||||
|
||||
e.g: Here `names`, `RGB`, `RRGGBB`, `RRGGBBAA` is enabled but not `rgb_fn` and `hsl_fn`
|
||||
|
||||
```lua
|
||||
require 'colorizer'.setup { user_default_options = { css_fn = false, css = true } }
|
||||
```
|
||||
|
||||
### Updating color even when buffer is not focused
|
||||
|
||||
Like in floating windows, popup menu, etc
|
||||
|
||||
use `always_update` flag. Use with caution, as this will update for any change in that buffer, whether focused or not.
|
||||
|
||||
```lua
|
||||
-- Alwyas update the color values in cmp_docs even if it not focused
|
||||
require 'colorizer'.setup {
|
||||
filetypes = {
|
||||
'*'; -- Highlight all files, but customize some others.
|
||||
cmp_docs = {always_update = true}
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
All the above examples can also be apply to buftypes. Also no buftypes trigger colorizer by default
|
||||
|
||||
Buftype value is fetched by `vim.bo.buftype`
|
||||
|
||||
```lua
|
||||
-- need to specify buftypes
|
||||
require 'colorizer'.setup(
|
||||
buftypes = {
|
||||
"*",
|
||||
-- exclude prompt and popup buftypes from highlight
|
||||
"!prompt",
|
||||
"!popup",
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
For lower level interface, see the [LuaDocs for API details](https://nvchad.com/nvim-colorizer.lua/modules/colorizer.html) or use `:h colorizer` once installed.
|
||||
|
||||
## Extras
|
||||
|
||||
Documentaion is generated using ldoc. See
|
||||
[scripts/gen_docs.sh](https://github.com/NvChad/nvim-colorizer.lua/blob/master/scripts/gen_docs.sh)
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] Add more colour types ( var, advanced css functions )
|
||||
- [ ] Add more display modes. E.g - sign column
|
||||
- [ ] Use a more space efficient trie implementation.
|
||||
|
||||
## Similar projects
|
||||
|
||||
[nvim-highlight-colors](https://github.com/brenoprata10/nvim-highlight-colors)
|
||||
|
||||
[vim-hexokinase](https://github.com/RRethy/vim-hexokinase)
|
||||
@ -1,910 +0,0 @@
|
||||
*colorizer* Requires Neovim >= 0.7.0 and `set termguicolors`
|
||||
|
||||
Highlights terminal CSI ANSI color codes.
|
||||
|
||||
Author: Ashkan Kiani <from-nvim-colorizer.lua@kiani.io>
|
||||
|
||||
==============================================================================
|
||||
USAGE *colorizer-usage*
|
||||
|
||||
Establish the autocmd to highlight all filetypes.
|
||||
|
||||
`lua require 'colorizer'.setup()`
|
||||
|
||||
Highlight using all css highlight modes in every filetype
|
||||
|
||||
`lua require 'colorizer'.setup(user_default_options = { css = true; })`
|
||||
|
||||
==============================================================================
|
||||
USE WITH COMMANDS *colorizer-commands*
|
||||
|
||||
*:ColorizerAttachToBuffer*
|
||||
|
||||
Attach to the current buffer and start highlighting with the settings as
|
||||
specified in setup (or the defaults).
|
||||
|
||||
If the buffer was already attached(i.e. being highlighted), the
|
||||
settings will be reloaded with the ones from setup.
|
||||
This is useful for reloading settings for just one buffer.
|
||||
|
||||
*:ColorizerDetachFromBuffer*
|
||||
|
||||
Stop highlighting the current buffer (detach).
|
||||
|
||||
*:ColorizerReloadAllBuffers*
|
||||
|
||||
Reload all buffers that are being highlighted currently.
|
||||
Shortcut for ColorizerAttachToBuffer on every buffer.
|
||||
|
||||
*:ColorizerToggle*
|
||||
Toggle highlighting of the current buffer.
|
||||
|
||||
USE WITH LUA
|
||||
|
||||
All options that can be passed to user_default_options in `setup`
|
||||
can be passed here. Can be empty too.
|
||||
`0` is the buffer number here
|
||||
|
||||
Attach to current buffer >
|
||||
require("colorizer").attach_to_buffer(0, {
|
||||
mode = "background",
|
||||
css = false,
|
||||
})
|
||||
<
|
||||
Detach from buffer >
|
||||
require("colorizer").detach_from_buffer(0, {
|
||||
mode = "background",
|
||||
css = false,
|
||||
})
|
||||
<
|
||||
|
||||
See:~
|
||||
|colorizer.setup|
|
||||
|colorizer.attach_to_buffer|
|
||||
|colorizer.detach_from_buffer|
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|highlight_buffer| - Highlight the buffer region
|
||||
|
||||
|is_buffer_attached| - Check if attached to a buffer.
|
||||
|
||||
|detach_from_buffer| - Stop highlighting the current buffer.
|
||||
|
||||
|attach_to_buffer| - Attach to a buffer and continuously highlight changes.
|
||||
|
||||
|setup| - Easy to use function if you want the full setup without fine
|
||||
grained control.
|
||||
|
||||
|get_buffer_options| - Return the currently active buffer options.
|
||||
|
||||
|reload_all_buffers| - Reload all of the currently active highlighted
|
||||
buffers.
|
||||
|
||||
|clear_highlight_cache| - Clear the highlight cache and reload all buffers.
|
||||
|
||||
Tables: ~
|
||||
|user_default_options| - defaults options.
|
||||
|
||||
Fields: ~
|
||||
|DEFAULT_NAMESPACE| - Default namespace used in `colorizer.buffer.highlight`
|
||||
and `attach_to_buffer`.
|
||||
|
||||
|
||||
highlight_buffer() *colorizer.highlight_buffer*
|
||||
Highlight the buffer region
|
||||
|
||||
See also:~
|
||||
|colorizer.buffer.highlight|
|
||||
|
||||
|
||||
|
||||
is_buffer_attached({buf}) *colorizer.is_buffer_attached*
|
||||
Check if attached to a buffer.
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number|nil: A value of 0 implies the current buffer.
|
||||
|
||||
returns:~
|
||||
number or nil: if attached to the buffer, false otherwise.
|
||||
|
||||
See also:~
|
||||
|colorizer.buffer.highlight|
|
||||
|
||||
|
||||
|
||||
detach_from_buffer({buf}, {ns}) *colorizer.detach_from_buffer*
|
||||
Stop highlighting the current buffer.
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number|nil: buf A value of 0 or nil implies the current buffer.
|
||||
{ns} - number|nil: ns the namespace id, if not given DEFAULT_NAMESPACE
|
||||
is used
|
||||
|
||||
|
||||
|
||||
attach_to_buffer({buf}, {options}, {typ}) *colorizer.attach_to_buffer*
|
||||
Attach to a buffer and continuously highlight changes.
|
||||
|
||||
Parameters: ~
|
||||
{buf} - integer: A value of 0 implies the current buffer.
|
||||
{options} - table|nil: Configuration options as described in `setup`
|
||||
{typ} - string|nil: "buf" or "file" - The type of buffer option
|
||||
|
||||
|
||||
|
||||
setup({config}) *colorizer.setup*
|
||||
Easy to use function if you want the full setup without fine grained
|
||||
control.
|
||||
|
||||
Setup an autocmd which enables colorizing for the filetypes and options
|
||||
specified.
|
||||
|
||||
By default highlights all FileTypes.
|
||||
|
||||
Example config:~
|
||||
>
|
||||
{ filetypes = { "css", "html" }, user_default_options = { names = true } }
|
||||
<
|
||||
Setup with all the default options:~
|
||||
>
|
||||
require("colorizer").setup {
|
||||
filetypes = { "*" },
|
||||
user_default_options,
|
||||
-- all the sub-options of filetypes apply to buftypes
|
||||
buftypes = {},
|
||||
}
|
||||
<
|
||||
For all user_default_options, see |user_default_options|
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{config} - table: Config containing above parameters.
|
||||
|
||||
Usage:~
|
||||
`require'colorizer'.setup()`
|
||||
|
||||
|
||||
|
||||
get_buffer_options({buf}) *colorizer.get_buffer_options*
|
||||
Return the currently active buffer options.
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number|nil: Buffer number
|
||||
|
||||
returns:~
|
||||
table or nil
|
||||
|
||||
|
||||
|
||||
reload_all_buffers() *colorizer.reload_all_buffers*
|
||||
Reload all of the currently active highlighted buffers.
|
||||
|
||||
|
||||
|
||||
clear_highlight_cache() *colorizer.clear_highlight_cache*
|
||||
Clear the highlight cache and reload all buffers.
|
||||
|
||||
|
||||
|
||||
user_default_options *colorizer.user_default_options*
|
||||
defaults options.
|
||||
|
||||
In `user_default_options`, there are 2 types of options
|
||||
|
||||
1. Individual options - `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`,
|
||||
`rgb_fn` , `RRGGBBAA`, `AARRGGBB`, `tailwind`, `sass`
|
||||
|
||||
1. Alias options - `css`, `css_fn`
|
||||
|
||||
If `css_fn` is true, then `hsl_fn`, `rgb_fn` becomes `true`
|
||||
|
||||
If `css` is true, then `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`,
|
||||
`rgb_fn` becomes `true`
|
||||
|
||||
These options have a priority, Individual options have the highest priority,
|
||||
then alias options
|
||||
|
||||
For alias, `css_fn` has more priority over `css`
|
||||
|
||||
e.g: Here `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` is enabled but not
|
||||
`names`
|
||||
|
||||
>
|
||||
require 'colorizer'.setup { user_default_options = { names = false, css =
|
||||
true } }
|
||||
<
|
||||
|
||||
e.g: Here `names`, `RGB`, `RRGGBB`, `RRGGBBAA` is enabled but not `rgb_fn`
|
||||
and `hsl_fn`
|
||||
|
||||
>
|
||||
require 'colorizer'.setup { user_default_options = { css_fn = false, css =
|
||||
true } }
|
||||
<
|
||||
|
||||
>
|
||||
user_default_options = {
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
names = true, -- "Name" codes like Blue or blue
|
||||
RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||
AARRGGBB = false, -- 0xAARRGGBB hex codes
|
||||
rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB,
|
||||
RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
-- Available modes for `mode`: foreground, background, virtualtext
|
||||
mode = "background", -- Set the display mode.
|
||||
-- Available methods are false / true / "normal" / "lsp" / "both"
|
||||
-- True is same as normal
|
||||
tailwind = false, -- Enable tailwind colors
|
||||
-- parsers can contain values used in |user_default_options|
|
||||
sass = { enable = false, parsers = { css }, }, -- Enable sass colors
|
||||
virtualtext = "■",
|
||||
-- update color values even if buffer is not focused
|
||||
always_update = false
|
||||
}
|
||||
<
|
||||
|
||||
|
||||
Fields: ~
|
||||
{RGB} - boolean
|
||||
{RRGGBB} - boolean
|
||||
{names} - boolean
|
||||
{RRGGBBAA} - boolean
|
||||
{AARRGGBB} - boolean
|
||||
{rgb_fn} - boolean
|
||||
{hsl_fn} - boolean
|
||||
{css} - boolean
|
||||
{css_fn} - boolean
|
||||
{mode} - string
|
||||
{tailwind} - boolean|string
|
||||
{sass} - table
|
||||
{virtualtext} - string
|
||||
{always_update} - boolean
|
||||
|
||||
|
||||
|
||||
DEFAULT_NAMESPACE *colorizer.DEFAULT_NAMESPACE*
|
||||
Default namespace used in `colorizer.buffer.highlight` and
|
||||
`attach_to_buffer`.
|
||||
|
||||
See also:~
|
||||
|colorizer.buffer.highlight|
|
||||
|attach_to_buffer|
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
BUFFER *colorizer.buffer-introduction*
|
||||
|
||||
Helper functions to highlight buffer smartly
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.buffer-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|clear_hl_cache| - Clean the highlight cache
|
||||
|
||||
|add_highlight| - Create highlight and set highlights
|
||||
|
||||
|highlight| - Highlight the buffer region.
|
||||
|
||||
|parse_lines| - Parse the given lines for colors and return a table
|
||||
containing
|
||||
rgb_hex and range per line
|
||||
|
||||
|rehighlight| - Rehighlight the buffer if colorizer is active
|
||||
|
||||
Tables: ~
|
||||
|highlight_mode_names| - Highlight mode which will be use to render the
|
||||
colour
|
||||
|
||||
Fields: ~
|
||||
|default_namespace| - Default namespace used in `highlight` and
|
||||
`colorizer.attach_to_buffer`.
|
||||
|
||||
|
||||
clear_hl_cache() *colorizer.buffer.clear_hl_cache*
|
||||
Clean the highlight cache
|
||||
|
||||
|
||||
|
||||
|
||||
*colorizer.buffer.add_highlight*
|
||||
add_highlight({buf}, {ns}, {line_start}, {line_end}, {data}, {options})
|
||||
Create highlight and set highlights
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number
|
||||
{ns} - number
|
||||
{line_start} - number
|
||||
{line_end} - number
|
||||
{data} - table: table output of `parse_lines`
|
||||
{options} - table: Passed in setup, mainly for `user_default_options`
|
||||
|
||||
|
||||
|
||||
|
||||
*colorizer.buffer.highlight*
|
||||
highlight({buf}, {ns}, {line_start}, {line_end}, {options}, {options_local})
|
||||
Highlight the buffer region.
|
||||
|
||||
Highlight starting from `line_start` (0-indexed) for each line described by
|
||||
`lines` in the
|
||||
buffer `buf` and attach it to the namespace `ns`.
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number: buffer id
|
||||
{ns} - number: The namespace id. Default is DEFAULT_NAMESPACE. Create
|
||||
it with `vim.api.nvim_create_namespace`
|
||||
{line_start} - number: line_start should be 0-indexed
|
||||
{line_end} - number: Last line to highlight
|
||||
{options} - table: Configuration options as described in `setup`
|
||||
{options_local} - table: Buffer local variables
|
||||
|
||||
returns:~
|
||||
nil or boolean or number,table
|
||||
|
||||
|
||||
|
||||
|
||||
*colorizer.buffer.parse_lines*
|
||||
parse_lines({buf}, {lines}, {line_start}, {options})
|
||||
Parse the given lines for colors and return a table containing
|
||||
rgb_hex and range per line
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number
|
||||
{lines} - table
|
||||
{line_start} - number: This is the buffer line number, from where to
|
||||
start highlighting
|
||||
{options} - table: Passed in `colorizer.setup`, Only uses
|
||||
`user_default_options`
|
||||
|
||||
returns:~
|
||||
table or nil
|
||||
|
||||
|
||||
|
||||
|
||||
*colorizer.buffer.rehighlight*
|
||||
rehighlight({buf}, {options}, {options_local}, {use_local_lines})
|
||||
Rehighlight the buffer if colorizer is active
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number: Buffer number
|
||||
{options} - table: Buffer options
|
||||
{options_local} - table|nil: Buffer local variables
|
||||
{use_local_lines} - boolean|nil Whether to use lines num range from
|
||||
options_local
|
||||
|
||||
returns:~
|
||||
nil or boolean or number,table
|
||||
|
||||
|
||||
|
||||
highlight_mode_names *colorizer.buffer.highlight_mode_names*
|
||||
Highlight mode which will be use to render the colour
|
||||
|
||||
Fields: ~
|
||||
{background} -
|
||||
{foreground} -
|
||||
{virtualtext} -
|
||||
|
||||
|
||||
|
||||
default_namespace *colorizer.buffer.default_namespace*
|
||||
Default namespace used in `highlight` and `colorizer.attach_to_buffer`.
|
||||
|
||||
See also:~
|
||||
|highlight|
|
||||
|colorizer.attach_to_buffer|
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
COLOR *colorizer.color-introduction*
|
||||
|
||||
Helper color functions
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.color-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|hsl_to_rgb| - Converts an HSL color value to RGB.
|
||||
|
||||
|hue_to_rgb| - Convert hsl colour values to rgb.
|
||||
|
||||
|is_bright| - Determine whether to use black or white text.
|
||||
|
||||
|
||||
hsl_to_rgb({h}, {s}, {l}) *colorizer.color.hsl_to_rgb*
|
||||
Converts an HSL color value to RGB.
|
||||
|
||||
Parameters: ~
|
||||
{h} - number: Hue
|
||||
{s} - number: Saturation
|
||||
{l} - number: Lightness
|
||||
|
||||
returns:~
|
||||
number or nil,number or nil,number or nil
|
||||
|
||||
|
||||
|
||||
hue_to_rgb({p}, {q}, {t}) *colorizer.color.hue_to_rgb*
|
||||
Convert hsl colour values to rgb.
|
||||
|
||||
Source: https://gist.github.com/mjackson/5311256
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{p} - number
|
||||
{q} - number
|
||||
{t} - number
|
||||
|
||||
returns:~
|
||||
number
|
||||
|
||||
|
||||
|
||||
is_bright({r}, {g}, {b}) *colorizer.color.is_bright*
|
||||
Determine whether to use black or white text.
|
||||
|
||||
|
||||
ref: https://stackoverflow.com/a/1855903/837964
|
||||
https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{r} - number: Red
|
||||
{g} - number: Green
|
||||
{b} - number: Blue
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
MATCHER *colorizer.matcher-introduction*
|
||||
|
||||
Helper functions for colorizer to enable required parsers
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.matcher-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|compile| - Form a trie stuct with the given prefixes
|
||||
|
||||
|make| - Parse the given options and return a function with enabled parsers.
|
||||
|
||||
|
||||
compile({matchers}, {matchers_trie}) *colorizer.matcher.compile*
|
||||
Form a trie stuct with the given prefixes
|
||||
|
||||
Parameters: ~
|
||||
{matchers} - table: List of prefixes, {"rgb", "hsl"}
|
||||
{matchers_trie} - table: Table containing information regarding
|
||||
non-trie based parsers
|
||||
|
||||
returns:~
|
||||
function: function which will just parse the line for enabled parsers
|
||||
|
||||
|
||||
|
||||
make({options}) *colorizer.matcher.make*
|
||||
Parse the given options and return a function with enabled parsers.
|
||||
|
||||
if no parsers enabled then return false
|
||||
Do not try make the function again if it is present in the cache
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{options} - table: options created in `colorizer.setup`
|
||||
|
||||
returns:~
|
||||
function or boolean: function which will just parse the line for enabled
|
||||
parsers
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
ARGB_HEX *colorizer.parser.argb_hex-introduction*
|
||||
|
||||
Helper function to parse argb
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.parser.argb_hex-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|parser.argb_hex_parser| - parse for 0xaarrggbb and return rgb hex.
|
||||
|
||||
|
||||
|
||||
*colorizer.parser.argb_hex.parser.argb_hex_parser*
|
||||
parser.argb_hex_parser({line}, {i})
|
||||
parse for 0xaarrggbb and return rgb hex.
|
||||
|
||||
a format used in android apps
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{line} - string: line to parse
|
||||
{i} - number: index of line from where to start parsing
|
||||
|
||||
returns:~
|
||||
number or nil: index of line where the hex value ended
|
||||
string or nil: rgb hex value
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
HSL *colorizer.parser.hsl-introduction*
|
||||
|
||||
Helper function to parse argb
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.parser.hsl-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|parser.hsl_function_parser| - Parse for hsl() hsla() css function and
|
||||
return rgb hex.
|
||||
|
||||
|
||||
|
||||
*colorizer.parser.hsl.parser.hsl_function_parser*
|
||||
parser.hsl_function_parser({line}, {i}, {opts})
|
||||
Parse for hsl() hsla() css function and return rgb hex.
|
||||
|
||||
For more info:
|
||||
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{line} - string: Line to parse
|
||||
{i} - number: Index of line from where to start parsing
|
||||
{opts} - table: Values passed from matchers like prefix
|
||||
|
||||
returns:~
|
||||
number or nil: Index of line where the hsla/hsl function ended
|
||||
string or nil: rgb hex value
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
NAMES *colorizer.parser.names-introduction*
|
||||
|
||||
Helper function to parse argb
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.parser.names-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|parser.name_parser| - Grab all the colour values from
|
||||
`vim.api.nvim_get_color_map` and create a lookup table.
|
||||
|
||||
|
||||
|
||||
*colorizer.parser.names.parser.name_parser*
|
||||
parser.name_parser({line}, {i}, {opts})
|
||||
Grab all the colour values from `vim.api.nvim_get_color_map` and create a
|
||||
lookup table.
|
||||
|
||||
COLOR_MAP is used to store the colour values
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{line} - string: Line to parse
|
||||
{i} - number: Index of line from where to start parsing
|
||||
{opts} - table: Currently contains whether tailwind is enabled or not
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
RGBA_HEX *colorizer.parser.rgba_hex-introduction*
|
||||
|
||||
Helper function to parse argb
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.parser.rgba_hex-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|parser.rgba_hex_parser| - parse for #rrggbbaa and return rgb hex.
|
||||
|
||||
|
||||
|
||||
*colorizer.parser.rgba_hex.parser.rgba_hex_parser*
|
||||
parser.rgba_hex_parser({line}, {i}, {opts})
|
||||
parse for #rrggbbaa and return rgb hex.
|
||||
|
||||
a format used in android apps
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{line} - string: line to parse
|
||||
{i} - number: index of line from where to start parsing
|
||||
{opts} - table: Containing minlen, maxlen, valid_lengths
|
||||
|
||||
returns:~
|
||||
number or nil: index of line where the hex value ended
|
||||
string or nil: rgb hex value
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
RGB *colorizer.parser.rgb-introduction*
|
||||
|
||||
Helper function to parse argb
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.parser.rgb-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|parser.rgb_function_parser| - Parse for rgb() rgba() css function and
|
||||
return rgb hex.
|
||||
|
||||
|
||||
|
||||
*colorizer.parser.rgb.parser.rgb_function_parser*
|
||||
parser.rgb_function_parser({line}, {i}, {opts})
|
||||
Parse for rgb() rgba() css function and return rgb hex.
|
||||
|
||||
For more info:
|
||||
https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{line} - string: Line to parse
|
||||
{i} - number: Index of line from where to start parsing
|
||||
{opts} - table: Values passed from matchers like prefix
|
||||
|
||||
returns:~
|
||||
number or nil: Index of line where the rgb/rgba function ended
|
||||
string or nil: rgb hex value
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
SASS *colorizer.sass-introduction*
|
||||
|
||||
Helper functions to parse sass color variables
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.sass-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|cleanup| - Cleanup sass variables and watch handlers
|
||||
|
||||
|name_parser| - Parse the given line for sass color names
|
||||
check for value in SASS[buf].DEFINITIONS_ALL
|
||||
|
||||
|update_variables| - Parse the given lines for sass variabled and add to
|
||||
`SASS[buf].DEFINITIONS_ALL`.
|
||||
|
||||
|
||||
cleanup({buf}) *colorizer.sass.cleanup*
|
||||
Cleanup sass variables and watch handlers
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number
|
||||
|
||||
|
||||
|
||||
name_parser({line}, {i}, {buf}) *colorizer.sass.name_parser*
|
||||
Parse the given line for sass color names
|
||||
check for value in SASS[buf].DEFINITIONS_ALL
|
||||
|
||||
Parameters: ~
|
||||
{line} - string: Line to parse
|
||||
{i} - number: Index of line from where to start parsing
|
||||
{buf} - number
|
||||
|
||||
returns:~
|
||||
number or nil, string or nil
|
||||
|
||||
|
||||
|
||||
|
||||
*colorizer.sass.update_variables*
|
||||
update_variables({buf}, {line_start}, {line_end}, {lines}, {color_parser},
|
||||
{options}, {options_local})
|
||||
Parse the given lines for sass variabled and add to
|
||||
`SASS[buf].DEFINITIONS_ALL`.
|
||||
|
||||
which is then used in |sass_name_parser|
|
||||
If lines are not given, then fetch the lines with line_start and line_end
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number
|
||||
{line_start} - number
|
||||
{line_end} - number
|
||||
{lines} - table|nil
|
||||
{color_parser} - function|boolean
|
||||
{options} - table: Buffer options
|
||||
{options_local} - table|nil: Buffer local variables
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
TAILWIND *colorizer.tailwind-introduction*
|
||||
|
||||
Helper functions to parse tailwind color variables
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.tailwind-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|cleanup| - Cleanup tailwind variables and autocmd
|
||||
|
||||
|setup_lsp_colors| - highlight buffer using values returned by tailwindcss
|
||||
To see these table information, see |colorizer.buffer|
|
||||
|
||||
|
||||
cleanup({buf}) *colorizer.tailwind.cleanup*
|
||||
Cleanup tailwind variables and autocmd
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number
|
||||
|
||||
|
||||
|
||||
|
||||
*colorizer.tailwind.setup_lsp_colors*
|
||||
setup_lsp_colors({buf}, {options}, {options_local}, {add_highlight})
|
||||
highlight buffer using values returned by tailwindcss
|
||||
To see these table information, see |colorizer.buffer|
|
||||
|
||||
Parameters: ~
|
||||
{buf} - number
|
||||
{options} - table
|
||||
{options_local} - table
|
||||
{add_highlight} - function
|
||||
|
||||
|
||||
|
||||
==============================================================================
|
||||
TRIE *colorizer.trie-introduction*
|
||||
|
||||
Trie implementation in luajit.
|
||||
|
||||
todo: write documentation
|
||||
|
||||
|
||||
==============================================================================
|
||||
UTILS *colorizer.utils-introduction*
|
||||
|
||||
Helper utils
|
||||
|
||||
|
||||
==============================================================================
|
||||
LUA API *colorizer.utils-lua-api*
|
||||
|
||||
Functions: ~
|
||||
|byte_is_alphanumeric| - Obvious.
|
||||
|
||||
|byte_is_hex| - Obvious.
|
||||
|
||||
|byte_is_valid_colorchar| - Valid colorchars are alphanumeric and - (
|
||||
tailwind colors )
|
||||
|
||||
|count| - Count the number of character in a string
|
||||
|
||||
|get_last_modified| - Get last modified time of a file
|
||||
|
||||
|merge| - Merge two tables.
|
||||
|
||||
|parse_hex| - Obvious.
|
||||
|
||||
|watch_file| - Watch a file for changes and execute callback
|
||||
|
||||
|
||||
byte_is_alphanumeric({byte}) *colorizer.utils.byte_is_alphanumeric*
|
||||
Obvious.
|
||||
|
||||
Parameters: ~
|
||||
{byte} - number
|
||||
|
||||
returns:~
|
||||
boolean
|
||||
|
||||
|
||||
|
||||
byte_is_hex({byte}) *colorizer.utils.byte_is_hex*
|
||||
Obvious.
|
||||
|
||||
Parameters: ~
|
||||
{byte} - number
|
||||
|
||||
returns:~
|
||||
boolean
|
||||
|
||||
|
||||
|
||||
byte_is_valid_colorchar({byte}) *colorizer.utils.byte_is_valid_colorchar*
|
||||
Valid colorchars are alphanumeric and - ( tailwind colors )
|
||||
|
||||
Parameters: ~
|
||||
{byte} - number
|
||||
|
||||
returns:~
|
||||
boolean
|
||||
|
||||
|
||||
|
||||
count({str}, {pattern}) *colorizer.utils.count*
|
||||
Count the number of character in a string
|
||||
|
||||
Parameters: ~
|
||||
{str} - string
|
||||
{pattern} - string
|
||||
|
||||
returns:~
|
||||
number
|
||||
|
||||
|
||||
|
||||
get_last_modified({path}) *colorizer.utils.get_last_modified*
|
||||
Get last modified time of a file
|
||||
|
||||
Parameters: ~
|
||||
{path} - string: file path
|
||||
|
||||
returns:~
|
||||
number or nil: modified time
|
||||
|
||||
|
||||
|
||||
merge({...}) *colorizer.utils.merge*
|
||||
Merge two tables.
|
||||
|
||||
|
||||
todo: Remove this and use `vim.tbl_deep_extend`
|
||||
|
||||
|
||||
Parameters: ~
|
||||
{...} -
|
||||
|
||||
returns:~
|
||||
table
|
||||
|
||||
|
||||
|
||||
parse_hex({byte}) *colorizer.utils.parse_hex*
|
||||
Obvious.
|
||||
|
||||
Parameters: ~
|
||||
{byte} - number
|
||||
|
||||
returns:~
|
||||
number
|
||||
|
||||
|
||||
|
||||
watch_file({path}, {callback}, {...}) *colorizer.utils.watch_file*
|
||||
Watch a file for changes and execute callback
|
||||
|
||||
Parameters: ~
|
||||
{path} - string: File path
|
||||
{callback} - function: Callback to execute
|
||||
{...} - table: params for callback
|
||||
|
||||
returns:~
|
||||
function or nil
|
||||
|
||||
|
||||
|
||||
vim:tw=80:ts=8:noet:ft=help:norl:
|
||||
@ -1,119 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<table class="module_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.html">colorizer</a></td>
|
||||
<td class="summary">Requires Neovim >= 0.7.0 and <code>set termguicolors</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.buffer.html">colorizer.buffer</a></td>
|
||||
<td class="summary">Helper functions to highlight buffer smartly</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.color.html">colorizer.color</a></td>
|
||||
<td class="summary">Helper color functions</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.matcher.html">colorizer.matcher</a></td>
|
||||
<td class="summary">Helper functions for colorizer to enable required parsers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.parser.argb_hex.html">colorizer.parser.argb_hex</a></td>
|
||||
<td class="summary">Helper function to parse argb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.parser.hsl.html">colorizer.parser.hsl</a></td>
|
||||
<td class="summary">Helper function to parse argb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.parser.names.html">colorizer.parser.names</a></td>
|
||||
<td class="summary">Helper function to parse argb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.parser.rgb.html">colorizer.parser.rgb</a></td>
|
||||
<td class="summary">Helper function to parse argb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.parser.rgba_hex.html">colorizer.parser.rgba_hex</a></td>
|
||||
<td class="summary">Helper function to parse argb</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.sass.html">colorizer.sass</a></td>
|
||||
<td class="summary">Helper functions to parse sass color variables</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.tailwind.html">colorizer.tailwind</a></td>
|
||||
<td class="summary">Helper functions to parse tailwind color variables</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.trie.html">colorizer.trie</a></td>
|
||||
<td class="summary">Trie implementation in luajit.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="modules/colorizer.utils.html">colorizer.utils</a></td>
|
||||
<td class="summary">Helper utils</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,328 +0,0 @@
|
||||
@import url(https://fonts.googleapis.com/css?family=Quicksand:300,700);
|
||||
@import url(https://fonts.googleapis.com/css?family=Lato);
|
||||
|
||||
body {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
font-family: "Lato", arial, helvetica, geneva, sans-serif;
|
||||
background-color: #ffffff;
|
||||
margin: 0px;
|
||||
color: #1c4e68;
|
||||
}
|
||||
|
||||
code,
|
||||
tt {
|
||||
font-family: monospace;
|
||||
font-size: 1.1em;
|
||||
}
|
||||
span.parameter {
|
||||
font-family: monospace;
|
||||
}
|
||||
span.parameter:after {
|
||||
content: ":";
|
||||
}
|
||||
span.types:before {
|
||||
content: "(";
|
||||
}
|
||||
span.types:after {
|
||||
content: ")";
|
||||
}
|
||||
.type {
|
||||
font-weight: bold;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
body,
|
||||
p,
|
||||
td,
|
||||
th {
|
||||
font-size: 1em;
|
||||
line-height: 1.2em;
|
||||
}
|
||||
|
||||
p,
|
||||
ul {
|
||||
margin: 10px 0 0 0px;
|
||||
}
|
||||
|
||||
strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
em {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: "Quicksand", sans-serif;
|
||||
font-weight: 700;
|
||||
color: #ea316e;
|
||||
font-size: 1.5em;
|
||||
margin: 20px 0 20px 0;
|
||||
}
|
||||
h2,
|
||||
h3,
|
||||
h4 {
|
||||
font-family: "Quicksand", sans-serif;
|
||||
font-weight: 700;
|
||||
margin: 15px 0 10px 0;
|
||||
}
|
||||
h2 {
|
||||
font-size: 1.25em;
|
||||
color: #ea316e;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.15em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.06em;
|
||||
}
|
||||
|
||||
a:link {
|
||||
font-weight: bold;
|
||||
color: #1c4e68;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:visited {
|
||||
font-weight: bold;
|
||||
color: #1e86be;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
hr {
|
||||
color: #b1e3fa;
|
||||
background: #00007f;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin-left: 3em;
|
||||
}
|
||||
|
||||
ul {
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
p.name {
|
||||
font-family: "Andale Mono", monospace;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: rgb(245, 245, 245);
|
||||
border: 1px solid #c0c0c0; /* silver */
|
||||
padding: 10px;
|
||||
margin: 10px 0 10px 0;
|
||||
overflow: auto;
|
||||
font-family: "Andale Mono", monospace;
|
||||
}
|
||||
|
||||
pre.example {
|
||||
font-size: 0.85em;
|
||||
}
|
||||
|
||||
table.index {
|
||||
border: 1px #b1e3fa;
|
||||
}
|
||||
table.index td {
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin-left: 1em;
|
||||
margin-right: 1em;
|
||||
background-color: #e0f4fc;
|
||||
}
|
||||
|
||||
#product {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #b1e3fa;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#product big {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-color: #e0f4fc;
|
||||
border-left: 2px solid #b1e3fa;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
float: left;
|
||||
width: 14em;
|
||||
vertical-align: top;
|
||||
background-color: #e0f4fc;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
#navigation h2 {
|
||||
background-color: #aee7ff;
|
||||
font-size: 1.1em;
|
||||
color: #25aae1;
|
||||
text-align: left;
|
||||
padding: 0.2em;
|
||||
border-top: 1px solid #b1e3fa;
|
||||
border-bottom: 1px solid #b1e3fa;
|
||||
}
|
||||
|
||||
#navigation h1 {
|
||||
font-family: "Quicksand", sans-serif;
|
||||
font-weight: 300;
|
||||
font-size: 32px;
|
||||
padding-left: 20px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
#navigation ul {
|
||||
font-size: 1em;
|
||||
list-style-type: none;
|
||||
margin: 1px 1px 10px 1px;
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
#navigation li {
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
margin: 3px 0px 0px 22px;
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
#navigation li li a {
|
||||
margin: 0px 3px 0px -1em;
|
||||
}
|
||||
|
||||
#content {
|
||||
margin-left: 14em;
|
||||
padding: 1em;
|
||||
border-left: 2px solid #b1e3fa;
|
||||
border-right: 2px solid #b1e3fa;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#about {
|
||||
clear: both;
|
||||
padding: 5px;
|
||||
border-top: 2px solid #b1e3fa;
|
||||
background-color: #ffffff;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
font: 12pt "Times New Roman", "TimeNR", Times, serif;
|
||||
}
|
||||
a {
|
||||
font-weight: bold;
|
||||
color: #1c4e68;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#main {
|
||||
background-color: #ffffff;
|
||||
border-left: 0px;
|
||||
}
|
||||
|
||||
#container {
|
||||
margin-left: 2%;
|
||||
margin-right: 2%;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#content {
|
||||
padding: 1em;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
#navigation {
|
||||
display: none;
|
||||
}
|
||||
pre.example {
|
||||
font-family: "Andale Mono", monospace;
|
||||
font-size: 10pt;
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
|
||||
table.module_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #b1e3fa;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.module_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #b1e3fa;
|
||||
}
|
||||
table.module_list td.name {
|
||||
background-color: #e0f4fc;
|
||||
min-width: 200px;
|
||||
}
|
||||
table.module_list td.summary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
table.function_list {
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-color: #b1e3fa;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
table.function_list td {
|
||||
border-width: 1px;
|
||||
padding: 3px;
|
||||
border-style: solid;
|
||||
border-color: #b1e3fa;
|
||||
}
|
||||
table.function_list td.name {
|
||||
background-color: #e0f4fc;
|
||||
min-width: 200px;
|
||||
}
|
||||
table.function_list td.summary {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
ul.nowrap {
|
||||
overflow: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
dl.table dt,
|
||||
dl.function dt {
|
||||
border-top: 1px solid #b1e3fa;
|
||||
padding-top: 1em;
|
||||
}
|
||||
dl.table dd,
|
||||
dl.function dd {
|
||||
padding-bottom: 1em;
|
||||
margin: 10px 0 0 20px;
|
||||
}
|
||||
dl.table h3,
|
||||
dl.function h3 {
|
||||
font-size: 0.95em;
|
||||
}
|
||||
|
||||
/* stop sublists from having initial vertical space */
|
||||
ul ul {
|
||||
margin-top: 0px;
|
||||
}
|
||||
ol ul {
|
||||
margin-top: 0px;
|
||||
}
|
||||
ol ol {
|
||||
margin-top: 0px;
|
||||
}
|
||||
ul ol {
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
/* make the target distinct; helps when we're navigating to a function */
|
||||
a:target + * {
|
||||
background-color: #ff9;
|
||||
}
|
||||
@ -1,231 +0,0 @@
|
||||
# -- Yes this file is a huge mess but working with what we got
|
||||
# local header = '=============================================================================='
|
||||
# -- Most stuff copied from ldoc html tempelate
|
||||
# local no_spaces = ldoc.no_spaces
|
||||
# local use_li = ldoc.use_li
|
||||
# local display_name = ldoc.display_name
|
||||
# local iter = ldoc.modules.iter
|
||||
# local function M(txt,item) return ldoc.markup(txt,item,ldoc.plain) end
|
||||
# local nowrap = ""
|
||||
# local width = #header
|
||||
# local indentstr = ""
|
||||
# for i = 1, 4 do indentstr = indentstr .. " " end
|
||||
# local function new_header(start, e, noh, sep)
|
||||
# local s = " "
|
||||
# s = s:rep(width-(#e+ #start))
|
||||
# local w = #s + #start + #e
|
||||
# if w > width then
|
||||
# local s = " "
|
||||
# return (noh and "" or header) .. "\n\n".. s:rep(width - #e) .. sep .. e .. sep .. "\n" .. start
|
||||
# else
|
||||
# return (noh and "" or header) .. "\n" .. start .. s .. sep .. e .. sep
|
||||
# end
|
||||
# end
|
||||
#
|
||||
#local function magiclines( str )
|
||||
# local pos = 1;
|
||||
# return function()
|
||||
# if not pos then return nil end
|
||||
# local p1, p2 = str:find( "\r?\n", pos )
|
||||
# local line
|
||||
# if p1 then
|
||||
# line = str:sub( pos, p1 - 1 )
|
||||
# pos = p2 + 1
|
||||
# else
|
||||
# line = str:sub( pos )
|
||||
# pos = nil
|
||||
# end
|
||||
# return line
|
||||
# end
|
||||
#end
|
||||
# local function indent(s, n)
|
||||
# n = n or 1
|
||||
# local a = ""
|
||||
# local ss = indentstr:rep(n)
|
||||
# s = s:gsub("^", ss):gsub("\r?\n", "\n" .. ss)
|
||||
# -- to handle vim style comments
|
||||
# s = s:gsub(ss .. "<" , "<")
|
||||
# s = s:gsub(ss .. ">" , ">")
|
||||
# return s
|
||||
# end
|
||||
# if module then -- module documentation
|
||||
# local intro = module.name:gsub(".*%.", ""):upper()
|
||||
# if module.name == ldoc.project then
|
||||
*$(module.name)*$(indentstr)$(module.summary)
|
||||
|
||||
$(module.description)
|
||||
|
||||
# else
|
||||
$(new_header(intro, module.name .. "-introduction", false, "*"))
|
||||
|
||||
$(module.summary)
|
||||
$(module.description)
|
||||
# end
|
||||
# if module.info then
|
||||
# for tag, value in module.info:iter() do
|
||||
$(tag): $(value)
|
||||
# end
|
||||
# end -- if module.info
|
||||
|
||||
# if module.usage then
|
||||
$(new_header("USAGE", module.name .. "-usage", false, "*"))
|
||||
|
||||
# for usage in iter(module.usage) do
|
||||
$(usage)
|
||||
# end -- for
|
||||
# end -- if usage
|
||||
# if module.tags.include then
|
||||
$(M(ldoc.include_file(module.tags.include)))
|
||||
# end
|
||||
# if module.see then
|
||||
$(indent("See:"))~
|
||||
# for see in iter(module.see) do
|
||||
$(indent("|" .. see.label, 2))|
|
||||
# end -- for
|
||||
|
||||
# end -- if see
|
||||
# if not ldoc.no_summary then
|
||||
# local function_present = true
|
||||
# -- bang out the tables of item types for this module (e.g Functions, Tables, etc)
|
||||
# for kind,items in module.kinds() do
|
||||
# if function_present then
|
||||
$(new_header("LUA API", module.name .. "-lua-api", false, "*"))
|
||||
|
||||
# end
|
||||
# function_present = false
|
||||
$(kind): ~
|
||||
# for item in items() do
|
||||
$(indentstr)|$(item.name)| - $(M(item.summary,item))
|
||||
|
||||
# end -- for items
|
||||
#end -- for kinds
|
||||
#end -- if not no_summary
|
||||
# --- currently works for both Functions and Tables. The params field either contains
|
||||
# --- function parameters or table fields.
|
||||
# local show_return = not ldoc.no_return_or_parms
|
||||
# local show_parms = show_return
|
||||
# for kind, items in module.kinds() do
|
||||
# for item in items() do
|
||||
# local plist = ""
|
||||
# for parm in iter(item.params) do
|
||||
# local param,sublist = item:subparam(parm)
|
||||
# for p in iter(param) do
|
||||
# local name,tp,def = item:display_name_of(p), ldoc.typename(item:type_of_param(p)), item:default_of_param(p)
|
||||
# if plist == "" then
|
||||
# plist = "{" .. name .. "}"
|
||||
# else
|
||||
# plist = plist .. ", " .. "{" .. name .. "}"
|
||||
# end
|
||||
# end -- for
|
||||
# end
|
||||
# if item.type == "function" then
|
||||
$(new_header(item.name .. "(" .. plist .. ")", module.name .. "." .. item.name, true, "*"))
|
||||
# else
|
||||
$(new_header(item.name,module.name .. "." .. item.name , true, "*"))
|
||||
#end
|
||||
$(indent(item.summary))
|
||||
# if item.description ~= "" then
|
||||
$(indent(item.description))
|
||||
|
||||
# end
|
||||
# if ldoc.custom_tags then
|
||||
# for custom in iter(ldoc.custom_tags) do
|
||||
# local tag = item.tags[custom[1]]
|
||||
# if tag and not custom.hidden then
|
||||
# local li,il = use_li(tag)
|
||||
$(indentstr)$(indentstr)$(custom.title or custom[1]):
|
||||
# for value in iter(tag) do
|
||||
$(indentstr)$(indentstr)$(indentstr)$(custom.format and custom.format(value) or M(value))
|
||||
# end -- for
|
||||
# end -- if tag
|
||||
# end -- iter tags
|
||||
# end
|
||||
# if show_parms and item.params and #item.params > 0 then
|
||||
# local subnames = module.kinds:type_of(item).subnames
|
||||
# if subnames then
|
||||
|
||||
$(indentstr)$(subnames): ~
|
||||
# end
|
||||
# for parm in iter(item.params) do
|
||||
# local param,sublist = item:subparam(parm)
|
||||
# if sublist then
|
||||
$(sublist) - $(M(item.params.map[sublist],item))
|
||||
# end
|
||||
# for p in iter(param) do
|
||||
# local name,tp,def = item:display_name_of(p), ldoc.typename(item:type_of_param(p)), item:default_of_param(p)
|
||||
# if tp ~= '' then
|
||||
$(tp)
|
||||
# end
|
||||
$(indent("", 2)){$(name)} - $(M(item.params.map[p],item))
|
||||
# if def == true then
|
||||
(optional)
|
||||
# elseif def then
|
||||
(default $(def))
|
||||
# end
|
||||
# if item:readonly(p) then
|
||||
readonly
|
||||
# end
|
||||
# end
|
||||
# if sublist then
|
||||
# end
|
||||
# end -- for
|
||||
# end -- if params
|
||||
# if show_return and item.retgroups then local groups = item.retgroups
|
||||
|
||||
$(indentstr)returns:~
|
||||
# for i,group in ldoc.ipairs(groups) do local li,il = use_li(group)
|
||||
# for r in group:iter() do
|
||||
# local type, ctypes = item:return_type(r); local rt = ldoc.typename(type)
|
||||
# if rt ~= '' then
|
||||
$(rt)
|
||||
# end
|
||||
$(indent("", 2))$(r.text:gsub("|", " or "))
|
||||
# if ctypes then
|
||||
# for c in ctypes:iter() do
|
||||
$(c.name)
|
||||
$(ldoc.typename(c.type))
|
||||
$(M(c.comment,item))
|
||||
# end
|
||||
# end -- if ctypes
|
||||
# end -- for r
|
||||
# if i < #groups then
|
||||
Or
|
||||
# end
|
||||
# end -- for group
|
||||
# end -- if returns
|
||||
# if show_return and item.raise then
|
||||
Raises:
|
||||
$(M(item.raise,item))
|
||||
# end
|
||||
# if item.see then
|
||||
# local see_present = false
|
||||
# for see in iter(item.see) do
|
||||
# if not see_present then
|
||||
|
||||
$(indentstr)See also:~
|
||||
# end
|
||||
# see_present = true
|
||||
$(indentstr)$(indentstr)|$(see.label)|
|
||||
# end -- for
|
||||
# end -- if see
|
||||
|
||||
# if item.usage then
|
||||
$(indentstr)Usage:~
|
||||
# for usage in iter(item.usage) do
|
||||
$(indentstr)$(indentstr)$(usage)
|
||||
# end -- for
|
||||
# end -- if usage
|
||||
|
||||
# end -- for items
|
||||
# end -- for kinds
|
||||
|
||||
# else -- if module; project-level contents
|
||||
# for kind, mods in ldoc.kinds() do
|
||||
$(kind)
|
||||
# kind = kind:lower()
|
||||
# for m in mods() do
|
||||
$(nowrap) - "$(no_spaces(kind))/$(m.name).html" - $(m.name)
|
||||
$(M(ldoc.strip_header(m.summary),m))
|
||||
# end -- for modules
|
||||
# end -- for kinds
|
||||
# end -- if module
|
||||
@ -1,345 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><strong>buffer</strong></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.buffer</code></h1>
|
||||
<p>Helper functions to highlight buffer smartly</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#clear_hl_cache">clear_hl_cache ()</a></td>
|
||||
<td class="summary">Clean the highlight cache</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#add_highlight">add_highlight (buf, ns, line_start, line_end, data, options)</a></td>
|
||||
<td class="summary">Create highlight and set highlights</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#highlight">highlight (buf, ns, line_start, line_end, options, options_local)</a></td>
|
||||
<td class="summary">Highlight the buffer region.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parse_lines">parse_lines (buf, lines, line_start, options)</a></td>
|
||||
<td class="summary">Parse the given lines for colors and return a table containing
|
||||
rgb_hex and range per line</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#rehighlight">rehighlight (buf, options, options_local, use_local_lines)</a></td>
|
||||
<td class="summary">Rehighlight the buffer if colorizer is active</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#highlight_mode_names">highlight_mode_names</a></td>
|
||||
<td class="summary">Highlight mode which will be use to render the colour</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#default_namespace">default_namespace</a></td>
|
||||
<td class="summary">Default namespace used in <a href="../modules/colorizer.buffer.html#highlight">highlight</a> and <a href="../modules/colorizer.html#attach_to_buffer">colorizer.attach_to_buffer</a>.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "clear_hl_cache"></a>
|
||||
<strong>clear_hl_cache ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Clean the highlight cache
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "add_highlight"></a>
|
||||
<strong>add_highlight (buf, ns, line_start, line_end, data, options)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Create highlight and set highlights
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">ns</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">line_start</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">line_end</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">data</span>
|
||||
table: table output of <a href="../modules/colorizer.buffer.html#parse_lines">parse_lines</a>
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table: Passed in setup, mainly for <code>user_default_options</code>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "highlight"></a>
|
||||
<strong>highlight (buf, ns, line_start, line_end, options, options_local)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Highlight the buffer region.
|
||||
Highlight starting from <code>line_start</code> (0-indexed) for each line described by <code>lines</code> in the
|
||||
buffer <code>buf</code> and attach it to the namespace <code>ns</code>.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number: buffer id
|
||||
</li>
|
||||
<li><span class="parameter">ns</span>
|
||||
number: The namespace id. Default is DEFAULT_NAMESPACE. Create it with <code>vim.api.nvim_create_namespace</code>
|
||||
</li>
|
||||
<li><span class="parameter">line_start</span>
|
||||
number: line_start should be 0-indexed
|
||||
</li>
|
||||
<li><span class="parameter">line_end</span>
|
||||
number: Last line to highlight
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table: Configuration options as described in <code>setup</code>
|
||||
</li>
|
||||
<li><span class="parameter">options_local</span>
|
||||
table: Buffer local variables
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
nil|boolean|number,table
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "parse_lines"></a>
|
||||
<strong>parse_lines (buf, lines, line_start, options)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Parse the given lines for colors and return a table containing
|
||||
rgb_hex and range per line
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">lines</span>
|
||||
table
|
||||
</li>
|
||||
<li><span class="parameter">line_start</span>
|
||||
number: This is the buffer line number, from where to start highlighting
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table: Passed in <a href="../modules/colorizer.html#setup">colorizer.setup</a>, Only uses <code>user_default_options</code>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
table|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "rehighlight"></a>
|
||||
<strong>rehighlight (buf, options, options_local, use_local_lines)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Rehighlight the buffer if colorizer is active
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number: Buffer number
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table: Buffer options
|
||||
</li>
|
||||
<li><span class="parameter">options_local</span>
|
||||
table|nil: Buffer local variables
|
||||
</li>
|
||||
<li><span class="parameter">use_local_lines</span>
|
||||
boolean|nil Whether to use lines num range from options_local
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
nil|boolean|number,table
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "highlight_mode_names"></a>
|
||||
<strong>highlight_mode_names</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Highlight mode which will be use to render the colour
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">background</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">foreground</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
<li><span class="parameter">virtualtext</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "default_namespace"></a>
|
||||
<strong>default_namespace</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Default namespace used in <a href="../modules/colorizer.buffer.html#highlight">highlight</a> and <a href="../modules/colorizer.html#attach_to_buffer">colorizer.attach_to_buffer</a>.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>See also:</h3>
|
||||
<ul>
|
||||
<li><a href="../modules/colorizer.buffer.html#highlight">highlight</a></li>
|
||||
<li><a href="../modules/colorizer.html#attach_to_buffer">colorizer.attach_to_buffer</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,193 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><strong>color</strong></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.color</code></h1>
|
||||
<p>Helper color functions</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#hsl_to_rgb">hsl_to_rgb (h, s, l)</a></td>
|
||||
<td class="summary">Converts an HSL color value to RGB.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#hue_to_rgb">hue_to_rgb (p, q, t)</a></td>
|
||||
<td class="summary">Convert hsl colour values to rgb.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_bright">is_bright (r, g, b)</a></td>
|
||||
<td class="summary">Determine whether to use black or white text.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "hsl_to_rgb"></a>
|
||||
<strong>hsl_to_rgb (h, s, l)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Converts an HSL color value to RGB.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">h</span>
|
||||
number: Hue
|
||||
</li>
|
||||
<li><span class="parameter">s</span>
|
||||
number: Saturation
|
||||
</li>
|
||||
<li><span class="parameter">l</span>
|
||||
number: Lightness
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number|nil,number|nil,number|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "hue_to_rgb"></a>
|
||||
<strong>hue_to_rgb (p, q, t)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Convert hsl colour values to rgb.
|
||||
Source: https://gist.github.com/mjackson/5311256
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">p</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">q</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">t</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_bright"></a>
|
||||
<strong>is_bright (r, g, b)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Determine whether to use black or white text. </p>
|
||||
|
||||
<p> ref: https://stackoverflow.com/a/1855903/837964
|
||||
https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">r</span>
|
||||
number: Red
|
||||
</li>
|
||||
<li><span class="parameter">g</span>
|
||||
number: Green
|
||||
</li>
|
||||
<li><span class="parameter">b</span>
|
||||
number: Blue
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,538 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
<li><a href="#Tables">Tables</a></li>
|
||||
<li><a href="#Fields">Fields</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><strong>colorizer</strong></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer</code></h1>
|
||||
<p>Requires Neovim >= 0.7.0 and <code>set termguicolors</code></p>
|
||||
<p>Highlights terminal CSI ANSI color codes.</p>
|
||||
<h3>See also:</h3>
|
||||
<ul>
|
||||
<li><a href="../modules/colorizer.html#setup">colorizer.setup</a></li>
|
||||
<li><a href="../modules/colorizer.html#attach_to_buffer">colorizer.attach_to_buffer</a></li>
|
||||
<li><a href="../modules/colorizer.html#detach_from_buffer">colorizer.detach_from_buffer</a></li>
|
||||
</ul>
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"> Establish the autocmd to highlight all filetypes.
|
||||
|
||||
`lua require 'colorizer'.setup()`
|
||||
|
||||
Highlight using all css highlight modes in every filetype
|
||||
|
||||
`lua require 'colorizer'.setup(user_default_options = { css = true; })`
|
||||
|
||||
==============================================================================
|
||||
USE WITH COMMANDS *colorizer-commands*
|
||||
|
||||
*:ColorizerAttachToBuffer*
|
||||
|
||||
Attach to the current buffer and start highlighting with the settings as
|
||||
specified in setup (or the defaults).
|
||||
|
||||
If the buffer was already attached(i.e. being highlighted), the
|
||||
settings will be reloaded with the ones from setup.
|
||||
This is useful for reloading settings for just one buffer.
|
||||
|
||||
*:ColorizerDetachFromBuffer*
|
||||
|
||||
Stop highlighting the current buffer (detach).
|
||||
|
||||
*:ColorizerReloadAllBuffers*
|
||||
|
||||
Reload all buffers that are being highlighted currently.
|
||||
Shortcut for ColorizerAttachToBuffer on every buffer.
|
||||
|
||||
*:ColorizerToggle*
|
||||
Toggle highlighting of the current buffer.
|
||||
|
||||
USE WITH LUA
|
||||
|
||||
All options that can be passed to user_default_options in `setup`
|
||||
can be passed here. Can be empty too.
|
||||
`0` is the buffer number here
|
||||
|
||||
Attach to current buffer <pre>
|
||||
require("colorizer").attach_to_buffer(0, {
|
||||
mode = "background",
|
||||
css = false,
|
||||
})
|
||||
</pre>
|
||||
Detach from buffer <pre>
|
||||
require("colorizer").detach_from_buffer(0, {
|
||||
mode = "background",
|
||||
css = false,
|
||||
})
|
||||
</pre>
|
||||
</pre>
|
||||
</ul>
|
||||
<h3>Info:</h3>
|
||||
<ul>
|
||||
<li><strong>Author</strong>: Ashkan Kiani <a href="mailto:from-nvim-colorizer.lua@kiani.io">from-nvim-colorizer.lua@kiani.io</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#highlight_buffer">highlight_buffer ()</a></td>
|
||||
<td class="summary">Highlight the buffer region</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#is_buffer_attached">is_buffer_attached (buf)</a></td>
|
||||
<td class="summary">Check if attached to a buffer.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#detach_from_buffer">detach_from_buffer (buf, ns)</a></td>
|
||||
<td class="summary">Stop highlighting the current buffer.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#attach_to_buffer">attach_to_buffer (buf, options, typ)</a></td>
|
||||
<td class="summary">Attach to a buffer and continuously highlight changes.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#setup">setup (config)</a></td>
|
||||
<td class="summary">Easy to use function if you want the full setup without fine grained control.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_buffer_options">get_buffer_options (buf)</a></td>
|
||||
<td class="summary">Return the currently active buffer options.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#reload_all_buffers">reload_all_buffers ()</a></td>
|
||||
<td class="summary">Reload all of the currently active highlighted buffers.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#clear_highlight_cache">clear_highlight_cache ()</a></td>
|
||||
<td class="summary">Clear the highlight cache and reload all buffers.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Tables">Tables</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#user_default_options">user_default_options</a></td>
|
||||
<td class="summary">defaults options.</td>
|
||||
</tr>
|
||||
</table>
|
||||
<h2><a href="#Fields">Fields</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#DEFAULT_NAMESPACE">DEFAULT_NAMESPACE</a></td>
|
||||
<td class="summary">Default namespace used in <a href="../modules/colorizer.buffer.html#highlight">colorizer.buffer.highlight</a> and <a href="../modules/colorizer.html#attach_to_buffer">attach_to_buffer</a>.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "highlight_buffer"></a>
|
||||
<strong>highlight_buffer ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Highlight the buffer region
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>See also:</h3>
|
||||
<ul>
|
||||
<a href="../modules/colorizer.buffer.html#highlight">colorizer.buffer.highlight</a>
|
||||
</ul>
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "is_buffer_attached"></a>
|
||||
<strong>is_buffer_attached (buf)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Check if attached to a buffer.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number|nil: A value of 0 implies the current buffer.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number|nil: if attached to the buffer, false otherwise.
|
||||
</ol>
|
||||
|
||||
|
||||
<h3>See also:</h3>
|
||||
<ul>
|
||||
<a href="../modules/colorizer.buffer.html#highlight">colorizer.buffer.highlight</a>
|
||||
</ul>
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "detach_from_buffer"></a>
|
||||
<strong>detach_from_buffer (buf, ns)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Stop highlighting the current buffer.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number|nil: buf A value of 0 or nil implies the current buffer.
|
||||
</li>
|
||||
<li><span class="parameter">ns</span>
|
||||
number|nil: ns the namespace id, if not given DEFAULT_NAMESPACE is used
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "attach_to_buffer"></a>
|
||||
<strong>attach_to_buffer (buf, options, typ)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Attach to a buffer and continuously highlight changes.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
integer: A value of 0 implies the current buffer.
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table|nil: Configuration options as described in <a href="../modules/colorizer.html#setup">setup</a>
|
||||
</li>
|
||||
<li><span class="parameter">typ</span>
|
||||
string|nil: "buf" or "file" - The type of buffer option
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "setup"></a>
|
||||
<strong>setup (config)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Easy to use function if you want the full setup without fine grained control.
|
||||
Setup an autocmd which enables colorizing for the filetypes and options specified.</p>
|
||||
|
||||
<p>By default highlights all FileTypes.</p>
|
||||
|
||||
<p>Example config:~</p>
|
||||
|
||||
<pre>
|
||||
{ filetypes = { "css", "html" }, user_default_options = { names = true } }
|
||||
</pre>
|
||||
|
||||
<p>Setup with all the default options:~</p>
|
||||
|
||||
<pre>
|
||||
require("colorizer").setup {
|
||||
filetypes = { "*" },
|
||||
user_default_options,
|
||||
-- all the sub-options of filetypes apply to buftypes
|
||||
buftypes = {},
|
||||
}
|
||||
</pre>
|
||||
|
||||
<p>For all user<em>default</em>options, see |user<em>default</em>options|
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">config</span>
|
||||
table: Config containing above parameters.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Usage:</h3>
|
||||
<ul>
|
||||
<pre class="example"><span class="backtick"><code>require'colorizer'.setup()</code></span></pre>
|
||||
</ul>
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_buffer_options"></a>
|
||||
<strong>get_buffer_options (buf)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Return the currently active buffer options.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number|nil: Buffer number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
table|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "reload_all_buffers"></a>
|
||||
<strong>reload_all_buffers ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Reload all of the currently active highlighted buffers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "clear_highlight_cache"></a>
|
||||
<strong>clear_highlight_cache ()</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Clear the highlight cache and reload all buffers.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Tables"></a>Tables</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "user_default_options"></a>
|
||||
<strong>user_default_options</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
|
||||
<p>defaults options.
|
||||
In <a href="../modules/colorizer.html#user_default_options">user_default_options</a>, there are 2 types of options</p>
|
||||
|
||||
<ol>
|
||||
<li><p>Individual options - <code>names</code>, <code>RGB</code>, <code>RRGGBB</code>, <code>RRGGBBAA</code>, <code>hsl_fn</code>, <code>rgb_fn</code> , <code>RRGGBBAA</code>, <code>AARRGGBB</code>, <code>tailwind</code>, <code>sass</code></p></li>
|
||||
<li><p>Alias options - <code>css</code>, <code>css_fn</code></p></li>
|
||||
</ol>
|
||||
|
||||
<p>If <code>css_fn</code> is true, then <code>hsl_fn</code>, <code>rgb_fn</code> becomes <code>true</code></p>
|
||||
|
||||
<p>If <code>css</code> is true, then <code>names</code>, <code>RGB</code>, <code>RRGGBB</code>, <code>RRGGBBAA</code>, <code>hsl_fn</code>, <code>rgb_fn</code> becomes <code>true</code></p>
|
||||
|
||||
<p>These options have a priority, Individual options have the highest priority, then alias options</p>
|
||||
|
||||
<p>For alias, <code>css_fn</code> has more priority over <code>css</code></p>
|
||||
|
||||
<p>e.g: Here <code>RGB</code>, <code>RRGGBB</code>, <code>RRGGBBAA</code>, <code>hsl_fn</code>, <code>rgb_fn</code> is enabled but not <code>names</code></p>
|
||||
|
||||
|
||||
<pre>
|
||||
require 'colorizer'.setup { user_default_options = { names = false, css = true } }
|
||||
</pre>
|
||||
|
||||
|
||||
<p>e.g: Here <code>names</code>, <code>RGB</code>, <code>RRGGBB</code>, <code>RRGGBBAA</code> is enabled but not <code>rgb_fn</code> and <code>hsl_fn</code></p>
|
||||
|
||||
|
||||
<pre>
|
||||
require 'colorizer'.setup { user_default_options = { css_fn = false, css = true } }
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
<pre>
|
||||
user_default_options = {
|
||||
RGB = true, -- #RGB hex codes
|
||||
RRGGBB = true, -- #RRGGBB hex codes
|
||||
names = true, -- "Name" codes like Blue or blue
|
||||
RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||
AARRGGBB = false, -- 0xAARRGGBB hex codes
|
||||
rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||
hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
-- Available modes for <code>mode</code>: foreground, background, virtualtext
|
||||
mode = "background", -- Set the display mode.
|
||||
-- Available methods are false / true / "normal" / "lsp" / "both"
|
||||
-- True is same as normal
|
||||
tailwind = false, -- Enable tailwind colors
|
||||
-- parsers can contain values used in |user_default_options|
|
||||
sass = { enable = false, parsers = { css }, }, -- Enable sass colors
|
||||
virtualtext = "■",
|
||||
-- update color values even if buffer is not focused
|
||||
always_update = false
|
||||
}
|
||||
</pre>
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>Fields:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">RGB</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">RRGGBB</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">names</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">RRGGBBAA</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">AARRGGBB</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">rgb_fn</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">hsl_fn</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">css</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">css_fn</span>
|
||||
boolean
|
||||
</li>
|
||||
<li><span class="parameter">mode</span>
|
||||
string
|
||||
</li>
|
||||
<li><span class="parameter">tailwind</span>
|
||||
boolean|string
|
||||
</li>
|
||||
<li><span class="parameter">sass</span>
|
||||
table
|
||||
</li>
|
||||
<li><span class="parameter">virtualtext</span>
|
||||
string
|
||||
</li>
|
||||
<li><span class="parameter">always_update</span>
|
||||
boolean
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
<h2 class="section-header "><a name="Fields"></a>Fields</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "DEFAULT_NAMESPACE"></a>
|
||||
<strong>DEFAULT_NAMESPACE</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Default namespace used in <a href="../modules/colorizer.buffer.html#highlight">colorizer.buffer.highlight</a> and <a href="../modules/colorizer.html#attach_to_buffer">attach_to_buffer</a>.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<h3>See also:</h3>
|
||||
<ul>
|
||||
<li><a href="../modules/colorizer.buffer.html#highlight">colorizer.buffer.highlight</a></li>
|
||||
<li><a href="../modules/colorizer.html#attach_to_buffer">attach_to_buffer</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,152 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><strong>matcher</strong></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.matcher</code></h1>
|
||||
<p>Helper functions for colorizer to enable required parsers</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#compile">compile (matchers, matchers_trie)</a></td>
|
||||
<td class="summary">Form a trie stuct with the given prefixes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#make">make (options)</a></td>
|
||||
<td class="summary">Parse the given options and return a function with enabled parsers.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "compile"></a>
|
||||
<strong>compile (matchers, matchers_trie)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Form a trie stuct with the given prefixes
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">matchers</span>
|
||||
table: List of prefixes, {"rgb", "hsl"}
|
||||
</li>
|
||||
<li><span class="parameter">matchers_trie</span>
|
||||
table: Table containing information regarding non-trie based parsers
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
function: function which will just parse the line for enabled parsers
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "make"></a>
|
||||
<strong>make (options)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Parse the given options and return a function with enabled parsers.
|
||||
if no parsers enabled then return false
|
||||
Do not try make the function again if it is present in the cache
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">options</span>
|
||||
table: options created in <a href="../modules/colorizer.html#setup">colorizer.setup</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
function|boolean: function which will just parse the line for enabled parsers
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,124 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><strong>parser.argb_hex</strong></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.parser.argb_hex</code></h1>
|
||||
<p>Helper function to parse argb</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parser.argb_hex_parser">parser.argb_hex_parser (line, i)</a></td>
|
||||
<td class="summary">parse for 0xaarrggbb and return rgb hex.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "parser.argb_hex_parser"></a>
|
||||
<strong>parser.argb_hex_parser (line, i)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
parse for 0xaarrggbb and return rgb hex.
|
||||
a format used in android apps
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">line</span>
|
||||
string: line to parse
|
||||
</li>
|
||||
<li><span class="parameter">i</span>
|
||||
number: index of line from where to start parsing
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
<li>
|
||||
number|nil: index of line where the hex value ended</li>
|
||||
<li>
|
||||
string|nil: rgb hex value</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,127 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><strong>parser.hsl</strong></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.parser.hsl</code></h1>
|
||||
<p>Helper function to parse argb</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parser.hsl_function_parser">parser.hsl_function_parser (line, i, opts)</a></td>
|
||||
<td class="summary">Parse for hsl() hsla() css function and return rgb hex.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "parser.hsl_function_parser"></a>
|
||||
<strong>parser.hsl_function_parser (line, i, opts)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Parse for hsl() hsla() css function and return rgb hex.
|
||||
For more info: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">line</span>
|
||||
string: Line to parse
|
||||
</li>
|
||||
<li><span class="parameter">i</span>
|
||||
number: Index of line from where to start parsing
|
||||
</li>
|
||||
<li><span class="parameter">opts</span>
|
||||
table: Values passed from matchers like prefix
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
<li>
|
||||
number|nil: Index of line where the hsla/hsl function ended</li>
|
||||
<li>
|
||||
string|nil: rgb hex value</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,120 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><strong>parser.names</strong></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.parser.names</code></h1>
|
||||
<p>Helper function to parse argb</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parser.name_parser">parser.name_parser (line, i, opts)</a></td>
|
||||
<td class="summary">Grab all the colour values from <code>vim.api.nvim_get_color_map</code> and create a lookup table.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "parser.name_parser"></a>
|
||||
<strong>parser.name_parser (line, i, opts)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Grab all the colour values from <code>vim.api.nvim_get_color_map</code> and create a lookup table.
|
||||
COLOR_MAP is used to store the colour values
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">line</span>
|
||||
string: Line to parse
|
||||
</li>
|
||||
<li><span class="parameter">i</span>
|
||||
number: Index of line from where to start parsing
|
||||
</li>
|
||||
<li><span class="parameter">opts</span>
|
||||
table: Currently contains whether tailwind is enabled or not
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,127 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><strong>parser.rgb</strong></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.parser.rgb</code></h1>
|
||||
<p>Helper function to parse argb</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parser.rgb_function_parser">parser.rgb_function_parser (line, i, opts)</a></td>
|
||||
<td class="summary">Parse for rgb() rgba() css function and return rgb hex.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "parser.rgb_function_parser"></a>
|
||||
<strong>parser.rgb_function_parser (line, i, opts)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Parse for rgb() rgba() css function and return rgb hex.
|
||||
For more info: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">line</span>
|
||||
string: Line to parse
|
||||
</li>
|
||||
<li><span class="parameter">i</span>
|
||||
number: Index of line from where to start parsing
|
||||
</li>
|
||||
<li><span class="parameter">opts</span>
|
||||
table: Values passed from matchers like prefix
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
<li>
|
||||
number|nil: Index of line where the rgb/rgba function ended</li>
|
||||
<li>
|
||||
string|nil: rgb hex value</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,127 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><strong>parser.rgba_hex</strong></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.parser.rgba_hex</code></h1>
|
||||
<p>Helper function to parse argb</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parser.rgba_hex_parser">parser.rgba_hex_parser (line, i, opts)</a></td>
|
||||
<td class="summary">parse for #rrggbbaa and return rgb hex.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "parser.rgba_hex_parser"></a>
|
||||
<strong>parser.rgba_hex_parser (line, i, opts)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
parse for #rrggbbaa and return rgb hex.
|
||||
a format used in android apps
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">line</span>
|
||||
string: line to parse
|
||||
</li>
|
||||
<li><span class="parameter">i</span>
|
||||
number: index of line from where to start parsing
|
||||
</li>
|
||||
<li><span class="parameter">opts</span>
|
||||
table: Containing minlen, maxlen, valid_lengths
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
<li>
|
||||
number|nil: index of line where the hex value ended</li>
|
||||
<li>
|
||||
string|nil: rgb hex value</li>
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,194 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><strong>sass</strong></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.sass</code></h1>
|
||||
<p>Helper functions to parse sass color variables</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#cleanup">cleanup (buf)</a></td>
|
||||
<td class="summary">Cleanup sass variables and watch handlers</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#name_parser">name_parser (line, i, buf)</a></td>
|
||||
<td class="summary">Parse the given line for sass color names
|
||||
check for value in SASS[buf].DEFINITIONS_ALL</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#update_variables">update_variables (buf, line_start, line_end, lines, color_parser, options, options_local)</a></td>
|
||||
<td class="summary">Parse the given lines for sass variabled and add to <code>SASS[buf].DEFINITIONS_ALL</code>.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "cleanup"></a>
|
||||
<strong>cleanup (buf)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Cleanup sass variables and watch handlers
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "name_parser"></a>
|
||||
<strong>name_parser (line, i, buf)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Parse the given line for sass color names
|
||||
check for value in SASS[buf].DEFINITIONS_ALL
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">line</span>
|
||||
string: Line to parse
|
||||
</li>
|
||||
<li><span class="parameter">i</span>
|
||||
number: Index of line from where to start parsing
|
||||
</li>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number|nil, string|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "update_variables"></a>
|
||||
<strong>update_variables (buf, line_start, line_end, lines, color_parser, options, options_local)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Parse the given lines for sass variabled and add to <code>SASS[buf].DEFINITIONS_ALL</code>.
|
||||
which is then used in |sass<em>name</em>parser|
|
||||
If lines are not given, then fetch the lines with line<em>start and line</em>end
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">line_start</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">line_end</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">lines</span>
|
||||
table|nil
|
||||
</li>
|
||||
<li><span class="parameter">color_parser</span>
|
||||
function|boolean
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table: Buffer options
|
||||
</li>
|
||||
<li><span class="parameter">options_local</span>
|
||||
table|nil: Buffer local variables
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,148 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><strong>tailwind</strong></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.tailwind</code></h1>
|
||||
<p>Helper functions to parse tailwind color variables</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#cleanup">cleanup (buf)</a></td>
|
||||
<td class="summary">Cleanup tailwind variables and autocmd</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#setup_lsp_colors">setup_lsp_colors (buf, options, options_local, add_highlight)</a></td>
|
||||
<td class="summary">highlight buffer using values returned by tailwindcss
|
||||
To see these table information, see |colorizer.buffer|</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "cleanup"></a>
|
||||
<strong>cleanup (buf)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Cleanup tailwind variables and autocmd
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "setup_lsp_colors"></a>
|
||||
<strong>setup_lsp_colors (buf, options, options_local, add_highlight)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
highlight buffer using values returned by tailwindcss
|
||||
To see these table information, see |colorizer.buffer|
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">buf</span>
|
||||
number
|
||||
</li>
|
||||
<li><span class="parameter">options</span>
|
||||
table
|
||||
</li>
|
||||
<li><span class="parameter">options_local</span>
|
||||
table
|
||||
</li>
|
||||
<li><span class="parameter">add_highlight</span>
|
||||
function
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,76 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><strong>trie</strong></li>
|
||||
<li><a href="../modules/colorizer.utils.html">utils</a></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.trie</code></h1>
|
||||
<p>Trie implementation in luajit.</p>
|
||||
<p>todo: write documentation</p>
|
||||
|
||||
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,334 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.parser.argb_hex.html">parser.argb_hex</a></li>
|
||||
<li><a href="../modules/colorizer.parser.hsl.html">parser.hsl</a></li>
|
||||
<li><a href="../modules/colorizer.parser.names.html">parser.names</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgb.html">parser.rgb</a></li>
|
||||
<li><a href="../modules/colorizer.parser.rgba_hex.html">parser.rgba_hex</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><strong>utils</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>colorizer.utils</code></h1>
|
||||
<p>Helper utils</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#byte_is_alphanumeric">byte_is_alphanumeric (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#byte_is_hex">byte_is_hex (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#byte_is_valid_colorchar">byte_is_valid_colorchar (byte)</a></td>
|
||||
<td class="summary">Valid colorchars are alphanumeric and - ( tailwind colors )</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#count">count (str, pattern)</a></td>
|
||||
<td class="summary">Count the number of character in a string</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_last_modified">get_last_modified (path)</a></td>
|
||||
<td class="summary">Get last modified time of a file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#merge">merge (...)</a></td>
|
||||
<td class="summary">Merge two tables.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parse_hex">parse_hex (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#watch_file">watch_file (path, callback, ...)</a></td>
|
||||
<td class="summary">Watch a file for changes and execute callback</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "byte_is_alphanumeric"></a>
|
||||
<strong>byte_is_alphanumeric (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
boolean
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "byte_is_hex"></a>
|
||||
<strong>byte_is_hex (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
boolean
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "byte_is_valid_colorchar"></a>
|
||||
<strong>byte_is_valid_colorchar (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Valid colorchars are alphanumeric and - ( tailwind colors )
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
boolean
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "count"></a>
|
||||
<strong>count (str, pattern)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Count the number of character in a string
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">str</span>
|
||||
string
|
||||
</li>
|
||||
<li><span class="parameter">pattern</span>
|
||||
string
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_last_modified"></a>
|
||||
<strong>get_last_modified (path)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get last modified time of a file
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">path</span>
|
||||
string: file path
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number|nil: modified time
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "merge"></a>
|
||||
<strong>merge (...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Merge two tables. </p>
|
||||
|
||||
<p> todo: Remove this and use <code>vim.tbl_deep_extend</code>
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">...</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
table
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "parse_hex"></a>
|
||||
<strong>parse_hex (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "watch_file"></a>
|
||||
<strong>watch_file (path, callback, ...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Watch a file for changes and execute callback
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">path</span>
|
||||
string: File path
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
function: Callback to execute
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
table: params for callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
function|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - February </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,326 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<head>
|
||||
<title>colorizer Docs</title>
|
||||
<link rel="stylesheet" href="../ldoc.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="container">
|
||||
|
||||
<div id="product">
|
||||
<div id="product_logo"></div>
|
||||
<div id="product_name"><big><b></b></big></div>
|
||||
<div id="product_description"></div>
|
||||
</div> <!-- id="product" -->
|
||||
|
||||
|
||||
<div id="main">
|
||||
|
||||
|
||||
<!-- Menu -->
|
||||
|
||||
<div id="navigation">
|
||||
<br/>
|
||||
<h1>colorizer</h1>
|
||||
|
||||
<ul>
|
||||
<li><a href="../index.html">Index</a></li>
|
||||
</ul>
|
||||
|
||||
<h2>Contents</h2>
|
||||
<ul>
|
||||
<li><a href="#Functions">Functions</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Modules</h2>
|
||||
<ul class="nowrap">
|
||||
<li><a href="../modules/colorizer.html">colorizer</a></li>
|
||||
<li><a href="../modules/colorizer.buffer.html">buffer</a></li>
|
||||
<li><a href="../modules/colorizer.color.html">color</a></li>
|
||||
<li><a href="../modules/colorizer.matcher.html">matcher</a></li>
|
||||
<li><a href="../modules/colorizer.sass.html">sass</a></li>
|
||||
<li><a href="../modules/colorizer.tailwind.html">tailwind</a></li>
|
||||
<li><a href="../modules/colorizer.trie.html">trie</a></li>
|
||||
<li><strong>utils</strong></li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
|
||||
<h1>Module <code>utils</code></h1>
|
||||
<p>Helper utils</p>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
<h2><a href="#Functions">Functions</a></h2>
|
||||
<table class="function_list">
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#byte_is_alphanumeric">byte_is_alphanumeric (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#byte_is_hex">byte_is_hex (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#byte_is_valid_colorchar">byte_is_valid_colorchar (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#get_last_modified">get_last_modified (path)</a></td>
|
||||
<td class="summary">Get last modified time of a file</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#merge">merge (...)</a></td>
|
||||
<td class="summary">Merge two tables.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#parse_hex">parse_hex (byte)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#percent_or_hex">percent_or_hex (v)</a></td>
|
||||
<td class="summary">Obvious.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="name" nowrap><a href="#watch_file">watch_file (path, callback, ...)</a></td>
|
||||
<td class="summary">Watch a file for changes and execute callback</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
|
||||
<h2 class="section-header "><a name="Functions"></a>Functions</h2>
|
||||
|
||||
<dl class="function">
|
||||
<dt>
|
||||
<a name = "byte_is_alphanumeric"></a>
|
||||
<strong>byte_is_alphanumeric (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
boolean
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "byte_is_hex"></a>
|
||||
<strong>byte_is_hex (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
boolean
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "byte_is_valid_colorchar"></a>
|
||||
<strong>byte_is_valid_colorchar (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
boolean
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "get_last_modified"></a>
|
||||
<strong>get_last_modified (path)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Get last modified time of a file
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">path</span>
|
||||
string: file path
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number|nil: modified time
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "merge"></a>
|
||||
<strong>merge (...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Merge two tables. </p>
|
||||
|
||||
<p> todo: Remove this and use <code>vim.tbl_deep_extend</code>
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">...</span>
|
||||
|
||||
|
||||
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
table
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "parse_hex"></a>
|
||||
<strong>parse_hex (byte)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">byte</span>
|
||||
number
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "percent_or_hex"></a>
|
||||
<strong>percent_or_hex (v)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Obvious.
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">v</span>
|
||||
string
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
number|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
<dt>
|
||||
<a name = "watch_file"></a>
|
||||
<strong>watch_file (path, callback, ...)</strong>
|
||||
</dt>
|
||||
<dd>
|
||||
Watch a file for changes and execute callback
|
||||
|
||||
|
||||
<h3>Parameters:</h3>
|
||||
<ul>
|
||||
<li><span class="parameter">path</span>
|
||||
string: File path
|
||||
</li>
|
||||
<li><span class="parameter">callback</span>
|
||||
function: Callback to execute
|
||||
</li>
|
||||
<li><span class="parameter">...</span>
|
||||
array: params for callback
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Returns:</h3>
|
||||
<ol>
|
||||
|
||||
function|nil
|
||||
</ol>
|
||||
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
|
||||
</div> <!-- id="content" -->
|
||||
</div> <!-- id="main" -->
|
||||
<div id="about">
|
||||
<i>generated by <a href="http://github.com/stevedonovan/LDoc">LDoc 1.4.6</a></i>
|
||||
<i style="float:right;">Last updated - September </i>
|
||||
</div> <!-- id="about" -->
|
||||
</div> <!-- id="container" -->
|
||||
</body>
|
||||
</html>
|
||||
@ -1,71 +0,0 @@
|
||||
:ColorizerAttachToBuffer colorizer.txt /*:ColorizerAttachToBuffer*
|
||||
:ColorizerDetachFromBuffer colorizer.txt /*:ColorizerDetachFromBuffer*
|
||||
:ColorizerReloadAllBuffers colorizer.txt /*:ColorizerReloadAllBuffers*
|
||||
:ColorizerToggle colorizer.txt /*:ColorizerToggle*
|
||||
colorizer colorizer.txt /*colorizer*
|
||||
colorizer-commands colorizer.txt /*colorizer-commands*
|
||||
colorizer-lua-api colorizer.txt /*colorizer-lua-api*
|
||||
colorizer-usage colorizer.txt /*colorizer-usage*
|
||||
colorizer.DEFAULT_NAMESPACE colorizer.txt /*colorizer.DEFAULT_NAMESPACE*
|
||||
colorizer.attach_to_buffer colorizer.txt /*colorizer.attach_to_buffer*
|
||||
colorizer.buffer-introduction colorizer.txt /*colorizer.buffer-introduction*
|
||||
colorizer.buffer-lua-api colorizer.txt /*colorizer.buffer-lua-api*
|
||||
colorizer.buffer.add_highlight colorizer.txt /*colorizer.buffer.add_highlight*
|
||||
colorizer.buffer.clear_hl_cache colorizer.txt /*colorizer.buffer.clear_hl_cache*
|
||||
colorizer.buffer.default_namespace colorizer.txt /*colorizer.buffer.default_namespace*
|
||||
colorizer.buffer.highlight colorizer.txt /*colorizer.buffer.highlight*
|
||||
colorizer.buffer.highlight_mode_names colorizer.txt /*colorizer.buffer.highlight_mode_names*
|
||||
colorizer.buffer.parse_lines colorizer.txt /*colorizer.buffer.parse_lines*
|
||||
colorizer.buffer.rehighlight colorizer.txt /*colorizer.buffer.rehighlight*
|
||||
colorizer.clear_highlight_cache colorizer.txt /*colorizer.clear_highlight_cache*
|
||||
colorizer.color-introduction colorizer.txt /*colorizer.color-introduction*
|
||||
colorizer.color-lua-api colorizer.txt /*colorizer.color-lua-api*
|
||||
colorizer.color.hsl_to_rgb colorizer.txt /*colorizer.color.hsl_to_rgb*
|
||||
colorizer.color.hue_to_rgb colorizer.txt /*colorizer.color.hue_to_rgb*
|
||||
colorizer.color.is_bright colorizer.txt /*colorizer.color.is_bright*
|
||||
colorizer.detach_from_buffer colorizer.txt /*colorizer.detach_from_buffer*
|
||||
colorizer.get_buffer_options colorizer.txt /*colorizer.get_buffer_options*
|
||||
colorizer.highlight_buffer colorizer.txt /*colorizer.highlight_buffer*
|
||||
colorizer.is_buffer_attached colorizer.txt /*colorizer.is_buffer_attached*
|
||||
colorizer.matcher-introduction colorizer.txt /*colorizer.matcher-introduction*
|
||||
colorizer.matcher-lua-api colorizer.txt /*colorizer.matcher-lua-api*
|
||||
colorizer.matcher.compile colorizer.txt /*colorizer.matcher.compile*
|
||||
colorizer.matcher.make colorizer.txt /*colorizer.matcher.make*
|
||||
colorizer.parser.argb_hex-introduction colorizer.txt /*colorizer.parser.argb_hex-introduction*
|
||||
colorizer.parser.argb_hex-lua-api colorizer.txt /*colorizer.parser.argb_hex-lua-api*
|
||||
colorizer.parser.argb_hex.parser.argb_hex_parser colorizer.txt /*colorizer.parser.argb_hex.parser.argb_hex_parser*
|
||||
colorizer.parser.hsl-introduction colorizer.txt /*colorizer.parser.hsl-introduction*
|
||||
colorizer.parser.hsl-lua-api colorizer.txt /*colorizer.parser.hsl-lua-api*
|
||||
colorizer.parser.hsl.parser.hsl_function_parser colorizer.txt /*colorizer.parser.hsl.parser.hsl_function_parser*
|
||||
colorizer.parser.names-introduction colorizer.txt /*colorizer.parser.names-introduction*
|
||||
colorizer.parser.names-lua-api colorizer.txt /*colorizer.parser.names-lua-api*
|
||||
colorizer.parser.names.parser.name_parser colorizer.txt /*colorizer.parser.names.parser.name_parser*
|
||||
colorizer.parser.rgb-introduction colorizer.txt /*colorizer.parser.rgb-introduction*
|
||||
colorizer.parser.rgb-lua-api colorizer.txt /*colorizer.parser.rgb-lua-api*
|
||||
colorizer.parser.rgb.parser.rgb_function_parser colorizer.txt /*colorizer.parser.rgb.parser.rgb_function_parser*
|
||||
colorizer.parser.rgba_hex-introduction colorizer.txt /*colorizer.parser.rgba_hex-introduction*
|
||||
colorizer.parser.rgba_hex-lua-api colorizer.txt /*colorizer.parser.rgba_hex-lua-api*
|
||||
colorizer.parser.rgba_hex.parser.rgba_hex_parser colorizer.txt /*colorizer.parser.rgba_hex.parser.rgba_hex_parser*
|
||||
colorizer.reload_all_buffers colorizer.txt /*colorizer.reload_all_buffers*
|
||||
colorizer.sass-introduction colorizer.txt /*colorizer.sass-introduction*
|
||||
colorizer.sass-lua-api colorizer.txt /*colorizer.sass-lua-api*
|
||||
colorizer.sass.cleanup colorizer.txt /*colorizer.sass.cleanup*
|
||||
colorizer.sass.name_parser colorizer.txt /*colorizer.sass.name_parser*
|
||||
colorizer.sass.update_variables colorizer.txt /*colorizer.sass.update_variables*
|
||||
colorizer.setup colorizer.txt /*colorizer.setup*
|
||||
colorizer.tailwind-introduction colorizer.txt /*colorizer.tailwind-introduction*
|
||||
colorizer.tailwind-lua-api colorizer.txt /*colorizer.tailwind-lua-api*
|
||||
colorizer.tailwind.cleanup colorizer.txt /*colorizer.tailwind.cleanup*
|
||||
colorizer.tailwind.setup_lsp_colors colorizer.txt /*colorizer.tailwind.setup_lsp_colors*
|
||||
colorizer.trie-introduction colorizer.txt /*colorizer.trie-introduction*
|
||||
colorizer.user_default_options colorizer.txt /*colorizer.user_default_options*
|
||||
colorizer.utils-introduction colorizer.txt /*colorizer.utils-introduction*
|
||||
colorizer.utils-lua-api colorizer.txt /*colorizer.utils-lua-api*
|
||||
colorizer.utils.byte_is_alphanumeric colorizer.txt /*colorizer.utils.byte_is_alphanumeric*
|
||||
colorizer.utils.byte_is_hex colorizer.txt /*colorizer.utils.byte_is_hex*
|
||||
colorizer.utils.byte_is_valid_colorchar colorizer.txt /*colorizer.utils.byte_is_valid_colorchar*
|
||||
colorizer.utils.count colorizer.txt /*colorizer.utils.count*
|
||||
colorizer.utils.get_last_modified colorizer.txt /*colorizer.utils.get_last_modified*
|
||||
colorizer.utils.merge colorizer.txt /*colorizer.utils.merge*
|
||||
colorizer.utils.parse_hex colorizer.txt /*colorizer.utils.parse_hex*
|
||||
colorizer.utils.watch_file colorizer.txt /*colorizer.utils.watch_file*
|
||||
@ -1,603 +0,0 @@
|
||||
--- Requires Neovim >= 0.7.0 and `set termguicolors`
|
||||
--
|
||||
--Highlights terminal CSI ANSI color codes.
|
||||
-- @module colorizer
|
||||
-- @author Ashkan Kiani <from-nvim-colorizer.lua@kiani.io>
|
||||
-- @usage Establish the autocmd to highlight all filetypes.
|
||||
--
|
||||
-- `lua require 'colorizer'.setup()`
|
||||
--
|
||||
-- Highlight using all css highlight modes in every filetype
|
||||
--
|
||||
-- `lua require 'colorizer'.setup(user_default_options = { css = true; })`
|
||||
--
|
||||
--==============================================================================
|
||||
--USE WITH COMMANDS *colorizer-commands*
|
||||
--
|
||||
-- *:ColorizerAttachToBuffer*
|
||||
--
|
||||
-- Attach to the current buffer and start highlighting with the settings as
|
||||
-- specified in setup (or the defaults).
|
||||
--
|
||||
-- If the buffer was already attached(i.e. being highlighted), the
|
||||
-- settings will be reloaded with the ones from setup.
|
||||
-- This is useful for reloading settings for just one buffer.
|
||||
--
|
||||
-- *:ColorizerDetachFromBuffer*
|
||||
--
|
||||
-- Stop highlighting the current buffer (detach).
|
||||
--
|
||||
-- *:ColorizerReloadAllBuffers*
|
||||
--
|
||||
-- Reload all buffers that are being highlighted currently.
|
||||
-- Shortcut for ColorizerAttachToBuffer on every buffer.
|
||||
--
|
||||
-- *:ColorizerToggle*
|
||||
-- Toggle highlighting of the current buffer.
|
||||
--
|
||||
--USE WITH LUA
|
||||
--
|
||||
-- All options that can be passed to user_default_options in `setup`
|
||||
-- can be passed here. Can be empty too.
|
||||
-- `0` is the buffer number here
|
||||
--
|
||||
-- Attach to current buffer <pre>
|
||||
-- require("colorizer").attach_to_buffer(0, {
|
||||
-- mode = "background",
|
||||
-- css = false,
|
||||
-- })
|
||||
--</pre>
|
||||
-- Detach from buffer <pre>
|
||||
-- require("colorizer").detach_from_buffer(0, {
|
||||
-- mode = "background",
|
||||
-- css = false,
|
||||
-- })
|
||||
--</pre>
|
||||
-- @see colorizer.setup
|
||||
-- @see colorizer.attach_to_buffer
|
||||
-- @see colorizer.detach_from_buffer
|
||||
|
||||
local buffer_utils = require "colorizer.buffer"
|
||||
local clear_hl_cache = buffer_utils.clear_hl_cache
|
||||
local rehighlight_buffer = buffer_utils.rehighlight
|
||||
|
||||
local utils = require "colorizer.utils"
|
||||
local merge = utils.merge
|
||||
|
||||
local api = vim.api
|
||||
local augroup = api.nvim_create_augroup
|
||||
local autocmd = api.nvim_create_autocmd
|
||||
local buf_get_option = api.nvim_buf_get_option
|
||||
local clear_namespace = api.nvim_buf_clear_namespace
|
||||
local current_buf = api.nvim_get_current_buf
|
||||
|
||||
local colorizer = {}
|
||||
|
||||
---Default namespace used in `colorizer.buffer.highlight` and `attach_to_buffer`.
|
||||
-- @see colorizer.buffer.highlight
|
||||
-- @see attach_to_buffer
|
||||
colorizer.DEFAULT_NAMESPACE = buffer_utils.default_namespace
|
||||
|
||||
---Highlight the buffer region
|
||||
---@function highlight_buffer
|
||||
-- @see colorizer.buffer.highlight
|
||||
colorizer.highlight_buffer = buffer_utils.highlight
|
||||
|
||||
-- USER FACING FUNCTIONALITY --
|
||||
local AUGROUP_ID
|
||||
local AUGROUP_NAME = "ColorizerSetup"
|
||||
-- buffer specific options given in setup
|
||||
local BUFFER_OPTIONS = {}
|
||||
-- buffer local options created after setup
|
||||
local BUFFER_LOCAL = {}
|
||||
-- the current buffer id, used in buf_attach calls
|
||||
local CURRENT_BUF = 0
|
||||
|
||||
---defaults options.
|
||||
--In `user_default_options`, there are 2 types of options
|
||||
--
|
||||
--1. Individual options - `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` , `RRGGBBAA`, `AARRGGBB`, `tailwind`, `sass`
|
||||
--
|
||||
--1. Alias options - `css`, `css_fn`
|
||||
--
|
||||
--If `css_fn` is true, then `hsl_fn`, `rgb_fn` becomes `true`
|
||||
--
|
||||
--If `css` is true, then `names`, `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` becomes `true`
|
||||
--
|
||||
--These options have a priority, Individual options have the highest priority, then alias options
|
||||
--
|
||||
--For alias, `css_fn` has more priority over `css`
|
||||
--
|
||||
--e.g: Here `RGB`, `RRGGBB`, `RRGGBBAA`, `hsl_fn`, `rgb_fn` is enabled but not `names`
|
||||
--
|
||||
--<pre>
|
||||
-- require 'colorizer'.setup { user_default_options = { names = false, css = true } }
|
||||
--</pre>
|
||||
--
|
||||
--e.g: Here `names`, `RGB`, `RRGGBB`, `RRGGBBAA` is enabled but not `rgb_fn` and `hsl_fn`
|
||||
--
|
||||
--<pre>
|
||||
-- require 'colorizer'.setup { user_default_options = { css_fn = false, css = true } }
|
||||
--</pre>
|
||||
--
|
||||
--<pre>
|
||||
-- user_default_options = {
|
||||
-- RGB = true, -- #RGB hex codes
|
||||
-- RRGGBB = true, -- #RRGGBB hex codes
|
||||
-- names = true, -- "Name" codes like Blue or blue
|
||||
-- RRGGBBAA = false, -- #RRGGBBAA hex codes
|
||||
-- AARRGGBB = false, -- 0xAARRGGBB hex codes
|
||||
-- rgb_fn = false, -- CSS rgb() and rgba() functions
|
||||
-- hsl_fn = false, -- CSS hsl() and hsla() functions
|
||||
-- css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB
|
||||
-- css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn
|
||||
-- -- Available modes for `mode`: foreground, background, virtualtext
|
||||
-- mode = "background", -- Set the display mode.
|
||||
-- -- Available methods are false / true / "normal" / "lsp" / "both"
|
||||
-- -- True is same as normal
|
||||
-- tailwind = false, -- Enable tailwind colors
|
||||
-- -- parsers can contain values used in |user_default_options|
|
||||
-- sass = { enable = false, parsers = { css }, }, -- Enable sass colors
|
||||
-- virtualtext = "■",
|
||||
-- -- update color values even if buffer is not focused
|
||||
-- always_update = false
|
||||
-- }
|
||||
--</pre>
|
||||
---@table user_default_options
|
||||
--@field RGB boolean
|
||||
--@field RRGGBB boolean
|
||||
--@field names boolean
|
||||
--@field RRGGBBAA boolean
|
||||
--@field AARRGGBB boolean
|
||||
--@field rgb_fn boolean
|
||||
--@field hsl_fn boolean
|
||||
--@field css boolean
|
||||
--@field css_fn boolean
|
||||
--@field mode string
|
||||
--@field tailwind boolean|string
|
||||
--@field sass table
|
||||
--@field virtualtext string
|
||||
--@field always_update boolean
|
||||
local USER_DEFAULT_OPTIONS = {
|
||||
RGB = true,
|
||||
RRGGBB = true,
|
||||
names = true,
|
||||
RRGGBBAA = false,
|
||||
AARRGGBB = false,
|
||||
rgb_fn = false,
|
||||
hsl_fn = false,
|
||||
css = false,
|
||||
css_fn = false,
|
||||
mode = "background",
|
||||
tailwind = false,
|
||||
sass = { enable = false, parsers = { css = true } },
|
||||
virtualtext = "■",
|
||||
always_update = false,
|
||||
}
|
||||
|
||||
local OPTIONS = { buf = {}, file = {} }
|
||||
local SETUP_SETTINGS = {
|
||||
exclusions = { buf = {}, file = {} },
|
||||
all = { file = false, buf = false },
|
||||
default_options = USER_DEFAULT_OPTIONS,
|
||||
}
|
||||
|
||||
--- Make new buffer Configuration
|
||||
---@param buf number: buffer number
|
||||
---@param typ string|nil: "buf" or "file" - The type of buffer option
|
||||
---@return table
|
||||
local function new_buffer_options(buf, typ)
|
||||
local value
|
||||
if typ == "buf" then
|
||||
value = buf_get_option(buf, "buftype")
|
||||
else
|
||||
value = buf_get_option(buf, "filetype")
|
||||
end
|
||||
return OPTIONS.file[value] or SETUP_SETTINGS.default_options
|
||||
end
|
||||
|
||||
--- Parse buffer Configuration and convert aliases to normal values
|
||||
---@param options table: options table
|
||||
---@return table
|
||||
local function parse_buffer_options(options)
|
||||
local includes = {
|
||||
["css"] = { "names", "RGB", "RRGGBB", "RRGGBBAA", "hsl_fn", "rgb_fn" },
|
||||
["css_fn"] = { "hsl_fn", "rgb_fn" },
|
||||
}
|
||||
local default_opts = USER_DEFAULT_OPTIONS
|
||||
|
||||
local function handle_alias(name, opts, d_opts)
|
||||
if not includes[name] then
|
||||
return
|
||||
end
|
||||
if opts == true or opts[name] == true then
|
||||
for _, child in ipairs(includes[name]) do
|
||||
d_opts[child] = true
|
||||
end
|
||||
elseif opts[name] == false then
|
||||
for _, child in ipairs(includes[name]) do
|
||||
d_opts[child] = false
|
||||
end
|
||||
end
|
||||
end
|
||||
-- https://github.com/NvChad/nvim-colorizer.lua/issues/48
|
||||
handle_alias("css", options, default_opts)
|
||||
handle_alias("css_fn", options, default_opts)
|
||||
|
||||
if options.sass then
|
||||
if type(options.sass.parsers) == "table" then
|
||||
for child, _ in pairs(options.sass.parsers) do
|
||||
handle_alias(child, options.sass.parsers, default_opts.sass.parsers)
|
||||
end
|
||||
else
|
||||
options.sass.parsers = {}
|
||||
for child, _ in pairs(default_opts.sass.parsers) do
|
||||
handle_alias(child, true, options.sass.parsers)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
options = merge(default_opts, options)
|
||||
return options
|
||||
end
|
||||
|
||||
--- Check if attached to a buffer.
|
||||
---@param buf number|nil: A value of 0 implies the current buffer.
|
||||
---@return number|nil: if attached to the buffer, false otherwise.
|
||||
---@see colorizer.buffer.highlight
|
||||
function colorizer.is_buffer_attached(buf)
|
||||
if buf == 0 or buf == nil then
|
||||
buf = current_buf()
|
||||
else
|
||||
if not api.nvim_buf_is_valid(buf) then
|
||||
BUFFER_LOCAL[buf], BUFFER_OPTIONS[buf] = nil, nil
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local au = api.nvim_get_autocmds {
|
||||
group = AUGROUP_ID,
|
||||
event = { "WinScrolled", "TextChanged", "TextChangedI", "TextChangedP" },
|
||||
buffer = buf,
|
||||
}
|
||||
if not BUFFER_OPTIONS[buf] or vim.tbl_isempty(au) then
|
||||
return
|
||||
end
|
||||
|
||||
return buf
|
||||
end
|
||||
|
||||
--- Stop highlighting the current buffer.
|
||||
---@param buf number|nil: buf A value of 0 or nil implies the current buffer.
|
||||
---@param ns number|nil: ns the namespace id, if not given DEFAULT_NAMESPACE is used
|
||||
function colorizer.detach_from_buffer(buf, ns)
|
||||
buf = colorizer.is_buffer_attached(buf)
|
||||
if not buf then
|
||||
return
|
||||
end
|
||||
|
||||
clear_namespace(buf, ns or colorizer.DEFAULT_NAMESPACE, 0, -1)
|
||||
if BUFFER_LOCAL[buf] then
|
||||
for _, namespace in pairs(BUFFER_LOCAL[buf].__detach.ns) do
|
||||
clear_namespace(buf, namespace, 0, -1)
|
||||
end
|
||||
|
||||
for _, f in pairs(BUFFER_LOCAL[buf].__detach.functions) do
|
||||
if type(f) == "function" then
|
||||
f(buf)
|
||||
end
|
||||
end
|
||||
|
||||
for _, id in ipairs(BUFFER_LOCAL[buf].__autocmds or {}) do
|
||||
pcall(api.nvim_del_autocmd, id)
|
||||
end
|
||||
|
||||
BUFFER_LOCAL[buf].__autocmds = nil
|
||||
BUFFER_LOCAL[buf].__detach = nil
|
||||
end
|
||||
-- because now the buffer is not visible, so delete its information
|
||||
BUFFER_OPTIONS[buf] = nil
|
||||
end
|
||||
|
||||
---Attach to a buffer and continuously highlight changes.
|
||||
---@param buf integer: A value of 0 implies the current buffer.
|
||||
---@param options table|nil: Configuration options as described in `setup`
|
||||
---@param typ string|nil: "buf" or "file" - The type of buffer option
|
||||
function colorizer.attach_to_buffer(buf, options, typ)
|
||||
if buf == 0 or buf == nil then
|
||||
buf = current_buf()
|
||||
else
|
||||
if not api.nvim_buf_is_valid(buf) then
|
||||
BUFFER_LOCAL[buf], BUFFER_OPTIONS[buf] = nil, nil
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- if the buffer is already attached then grab those options
|
||||
if not options then
|
||||
options = colorizer.get_buffer_options(buf)
|
||||
end
|
||||
|
||||
-- if not make new options
|
||||
if not options then
|
||||
options = new_buffer_options(buf, typ)
|
||||
end
|
||||
|
||||
options = parse_buffer_options(options)
|
||||
|
||||
if not buffer_utils.highlight_mode_names[options.mode] then
|
||||
if options.mode ~= nil then
|
||||
local mode = options.mode
|
||||
vim.defer_fn(function()
|
||||
-- just notify the user once
|
||||
vim.notify_once(string.format("Warning: Invalid mode given to colorizer setup [ %s ]", mode))
|
||||
end, 0)
|
||||
end
|
||||
options.mode = "background"
|
||||
end
|
||||
|
||||
BUFFER_OPTIONS[buf] = options
|
||||
|
||||
BUFFER_LOCAL[buf] = BUFFER_LOCAL[buf] or {}
|
||||
local highlighted, returns = rehighlight_buffer(buf, options)
|
||||
|
||||
if not highlighted then
|
||||
return
|
||||
end
|
||||
|
||||
BUFFER_LOCAL[buf].__detach = BUFFER_LOCAL[buf].__detach or returns.detach
|
||||
|
||||
BUFFER_LOCAL[buf].__init = true
|
||||
|
||||
if BUFFER_LOCAL[buf].__autocmds then
|
||||
return
|
||||
end
|
||||
|
||||
local autocmds = {}
|
||||
local au_group_id = AUGROUP_ID
|
||||
|
||||
local text_changed_au = { "TextChanged", "TextChangedI", "TextChangedP" }
|
||||
-- only enable InsertLeave in sass, rest don't require it
|
||||
if options.sass and options.sass.enable then
|
||||
table.insert(text_changed_au, "InsertLeave")
|
||||
end
|
||||
|
||||
if CURRENT_BUF == 0 then
|
||||
CURRENT_BUF = buf
|
||||
end
|
||||
|
||||
if options.always_update then
|
||||
-- attach using lua api so buffer gets updated even when not the current buffer
|
||||
-- completely moving to buf_attach is not possible because it doesn't handle all the text change events
|
||||
vim.api.nvim_buf_attach(buf, false, {
|
||||
on_lines = function(_, buffer)
|
||||
-- only reload if the buffer is not the current one
|
||||
if not (CURRENT_BUF == buffer) then
|
||||
-- only reload if it was not disabled using detach_from_buffer
|
||||
if BUFFER_OPTIONS[buf] then
|
||||
rehighlight_buffer(buf, options, BUFFER_LOCAL[buf])
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_reload = function(_, buffer)
|
||||
-- only reload if the buffer is not the current one
|
||||
if not (CURRENT_BUF == buffer) then
|
||||
-- only reload if it was not disabled using detach_from_buffer
|
||||
if BUFFER_OPTIONS[buf] then
|
||||
rehighlight_buffer(buf, options, BUFFER_LOCAL[buf])
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
autocmds[#autocmds + 1] = autocmd(text_changed_au, {
|
||||
group = au_group_id,
|
||||
buffer = buf,
|
||||
callback = function(args)
|
||||
CURRENT_BUF = buf
|
||||
-- only reload if it was not disabled using detach_from_buffer
|
||||
if BUFFER_OPTIONS[buf] then
|
||||
BUFFER_LOCAL[buf].__event = args.event
|
||||
if args.event == "TextChanged" or args.event == "InsertLeave" then
|
||||
rehighlight_buffer(buf, options, BUFFER_LOCAL[buf])
|
||||
else
|
||||
local pos = vim.fn.getpos "."
|
||||
BUFFER_LOCAL[buf].__startline = pos[2] - 1
|
||||
BUFFER_LOCAL[buf].__endline = pos[2]
|
||||
rehighlight_buffer(buf, options, BUFFER_LOCAL[buf], true)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
autocmds[#autocmds + 1] = autocmd({ "WinScrolled" }, {
|
||||
group = au_group_id,
|
||||
buffer = buf,
|
||||
callback = function(args)
|
||||
-- only reload if it was not disabled using detach_from_buffer
|
||||
if BUFFER_OPTIONS[buf] then
|
||||
BUFFER_LOCAL[buf].__event = args.event
|
||||
rehighlight_buffer(buf, options, BUFFER_LOCAL[buf])
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
autocmd({ "BufUnload", "BufDelete" }, {
|
||||
group = au_group_id,
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
if BUFFER_OPTIONS[buf] then
|
||||
colorizer.detach_from_buffer(buf)
|
||||
end
|
||||
BUFFER_LOCAL[buf].__init = nil
|
||||
end,
|
||||
})
|
||||
|
||||
BUFFER_LOCAL[buf].__autocmds = autocmds
|
||||
BUFFER_LOCAL[buf].__augroup_id = au_group_id
|
||||
end
|
||||
|
||||
---Easy to use function if you want the full setup without fine grained control.
|
||||
--Setup an autocmd which enables colorizing for the filetypes and options specified.
|
||||
--
|
||||
--By default highlights all FileTypes.
|
||||
--
|
||||
--Example config:~
|
||||
--<pre>
|
||||
-- { filetypes = { "css", "html" }, user_default_options = { names = true } }
|
||||
--</pre>
|
||||
--Setup with all the default options:~
|
||||
--<pre>
|
||||
-- require("colorizer").setup {
|
||||
-- filetypes = { "*" },
|
||||
-- user_default_options,
|
||||
-- -- all the sub-options of filetypes apply to buftypes
|
||||
-- buftypes = {},
|
||||
-- }
|
||||
--</pre>
|
||||
--For all user_default_options, see |user_default_options|
|
||||
---@param config table: Config containing above parameters.
|
||||
---@usage `require'colorizer'.setup()`
|
||||
function colorizer.setup(config)
|
||||
if not vim.opt.termguicolors then
|
||||
vim.schedule(function()
|
||||
vim.notify("Colorizer: Error: &termguicolors must be set", 4)
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
||||
local conf = vim.deepcopy(config) or {}
|
||||
|
||||
-- if nothing given the enable for all filetypes
|
||||
local filetypes = conf.filetypes or conf[1] or { "*" }
|
||||
local user_default_options = conf.user_default_options or conf[2] or {}
|
||||
local buftypes = conf.buftypes or conf[3] or nil
|
||||
|
||||
OPTIONS = { buf = {}, file = {} }
|
||||
SETUP_SETTINGS = {
|
||||
exclusions = { buf = {}, file = {} },
|
||||
all = { file = false, buf = false },
|
||||
default_options = user_default_options,
|
||||
}
|
||||
BUFFER_OPTIONS, BUFFER_LOCAL = {}, {}
|
||||
|
||||
local function COLORIZER_SETUP_HOOK(typ)
|
||||
local filetype = vim.bo.filetype
|
||||
local buftype = vim.bo.buftype
|
||||
local buf = current_buf()
|
||||
BUFFER_LOCAL[buf] = BUFFER_LOCAL[buf] or {}
|
||||
|
||||
if SETUP_SETTINGS.exclusions.file[filetype] or SETUP_SETTINGS.exclusions.buf[buftype] then
|
||||
-- when a filetype is disabled but buftype is enabled, it can Attach in
|
||||
-- some cases, so manually detach
|
||||
if BUFFER_OPTIONS[buf] then
|
||||
colorizer.detach_from_buffer(buf)
|
||||
end
|
||||
BUFFER_LOCAL[buf].__init = nil
|
||||
return
|
||||
end
|
||||
|
||||
local fopts, bopts, options = OPTIONS[typ][filetype], OPTIONS[typ][buftype], nil
|
||||
if typ == "file" then
|
||||
options = fopts
|
||||
-- if buffer and filetype options both are given, then prefer fileoptions
|
||||
elseif fopts and bopts then
|
||||
options = fopts
|
||||
else
|
||||
options = bopts
|
||||
end
|
||||
|
||||
if not options and not SETUP_SETTINGS.all[typ] then
|
||||
return
|
||||
end
|
||||
|
||||
options = options or SETUP_SETTINGS.default_options
|
||||
|
||||
-- this should ideally be triggered one time per buffer
|
||||
-- but BufWinEnter also triggers for split formation
|
||||
-- but we don't want that so add a check using local buffer variable
|
||||
if not BUFFER_LOCAL[buf].__init then
|
||||
colorizer.attach_to_buffer(buf, options, typ)
|
||||
end
|
||||
end
|
||||
|
||||
AUGROUP_ID = augroup(AUGROUP_NAME, {})
|
||||
|
||||
local aucmd = { buf = "BufWinEnter", file = "FileType" }
|
||||
local function parse_opts(typ, tbl)
|
||||
if type(tbl) == "table" then
|
||||
local list = {}
|
||||
|
||||
for k, v in pairs(tbl) do
|
||||
local value
|
||||
local options = SETUP_SETTINGS.default_options
|
||||
if type(k) == "string" then
|
||||
value = k
|
||||
if type(v) ~= "table" then
|
||||
vim.notify("colorizer: Invalid option type for " .. typ .. "type" .. value, 4)
|
||||
else
|
||||
options = merge(SETUP_SETTINGS.default_options, v)
|
||||
end
|
||||
else
|
||||
value = v
|
||||
end
|
||||
-- Exclude
|
||||
if value:sub(1, 1) == "!" then
|
||||
SETUP_SETTINGS.exclusions[typ][value:sub(2)] = true
|
||||
else
|
||||
OPTIONS[typ][value] = options
|
||||
if value == "*" then
|
||||
SETUP_SETTINGS.all[typ] = true
|
||||
else
|
||||
table.insert(list, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
autocmd({ aucmd[typ] }, {
|
||||
group = AUGROUP_ID,
|
||||
pattern = typ == "file" and (SETUP_SETTINGS.all[typ] and "*" or list) or nil,
|
||||
callback = function()
|
||||
COLORIZER_SETUP_HOOK(typ)
|
||||
end,
|
||||
})
|
||||
elseif tbl then
|
||||
vim.notify_once(string.format("colorizer: Invalid type for %stypes %s", typ, vim.inspect(tbl)), 4)
|
||||
end
|
||||
end
|
||||
|
||||
parse_opts("file", filetypes)
|
||||
parse_opts("buf", buftypes)
|
||||
|
||||
autocmd("ColorScheme", {
|
||||
group = AUGROUP_ID,
|
||||
callback = function()
|
||||
require("colorizer").clear_highlight_cache()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
--- Return the currently active buffer options.
|
||||
---@param buf number|nil: Buffer number
|
||||
---@return table|nil
|
||||
function colorizer.get_buffer_options(buf)
|
||||
local buffer = colorizer.is_buffer_attached(buf)
|
||||
if buffer then
|
||||
return BUFFER_OPTIONS[buffer]
|
||||
end
|
||||
end
|
||||
|
||||
--- Reload all of the currently active highlighted buffers.
|
||||
function colorizer.reload_all_buffers()
|
||||
for buf, _ in pairs(BUFFER_OPTIONS) do
|
||||
colorizer.attach_to_buffer(buf, colorizer.get_buffer_options(buf))
|
||||
end
|
||||
end
|
||||
|
||||
--- Clear the highlight cache and reload all buffers.
|
||||
function colorizer.clear_highlight_cache()
|
||||
clear_hl_cache()
|
||||
vim.schedule(colorizer.reload_all_buffers)
|
||||
end
|
||||
|
||||
return colorizer
|
||||
@ -1,268 +0,0 @@
|
||||
---Helper functions to highlight buffer smartly
|
||||
--@module colorizer.buffer
|
||||
local api = vim.api
|
||||
local buf_set_virtual_text = api.nvim_buf_set_extmark
|
||||
local buf_get_lines = api.nvim_buf_get_lines
|
||||
local create_namespace = api.nvim_create_namespace
|
||||
local clear_namespace = api.nvim_buf_clear_namespace
|
||||
local set_highlight = api.nvim_set_hl
|
||||
|
||||
local color = require "colorizer.color"
|
||||
local color_is_bright = color.is_bright
|
||||
|
||||
local make_matcher = require("colorizer.matcher").make
|
||||
|
||||
local sass = require "colorizer.sass"
|
||||
local sass_update_variables = sass.update_variables
|
||||
local sass_cleanup = sass.cleanup
|
||||
|
||||
local tailwind = require "colorizer.tailwind"
|
||||
local tailwind_setup_lsp = tailwind.setup_lsp_colors
|
||||
local tailwind_cleanup = tailwind.cleanup
|
||||
|
||||
local buffer = {}
|
||||
|
||||
local HIGHLIGHT_NAME_PREFIX = "colorizer"
|
||||
local HIGHLIGHT_CACHE = {}
|
||||
|
||||
--- Default namespace used in `highlight` and `colorizer.attach_to_buffer`.
|
||||
-- @see highlight
|
||||
-- @see colorizer.attach_to_buffer
|
||||
buffer.default_namespace = create_namespace "colorizer"
|
||||
|
||||
--- Highlight mode which will be use to render the colour
|
||||
buffer.highlight_mode_names = {
|
||||
background = "mb",
|
||||
foreground = "mf",
|
||||
virtualtext = "mv",
|
||||
}
|
||||
|
||||
--- Clean the highlight cache
|
||||
function buffer.clear_hl_cache()
|
||||
HIGHLIGHT_CACHE = {}
|
||||
end
|
||||
|
||||
--- Make a deterministic name for a highlight given these attributes
|
||||
local function make_highlight_name(rgb, mode)
|
||||
return table.concat({ HIGHLIGHT_NAME_PREFIX, buffer.highlight_mode_names[mode], rgb }, "_")
|
||||
end
|
||||
|
||||
local function create_highlight(rgb_hex, mode)
|
||||
mode = mode or "background"
|
||||
-- TODO validate rgb format?
|
||||
rgb_hex = rgb_hex:lower()
|
||||
local cache_key = table.concat({ buffer.highlight_mode_names[mode], rgb_hex }, "_")
|
||||
local highlight_name = HIGHLIGHT_CACHE[cache_key]
|
||||
|
||||
-- Look up in our cache.
|
||||
if highlight_name then
|
||||
return highlight_name
|
||||
end
|
||||
|
||||
-- convert from #fff to #ffffff
|
||||
if #rgb_hex == 3 then
|
||||
rgb_hex = table.concat {
|
||||
rgb_hex:sub(1, 1):rep(2),
|
||||
rgb_hex:sub(2, 2):rep(2),
|
||||
rgb_hex:sub(3, 3):rep(2),
|
||||
}
|
||||
end
|
||||
|
||||
-- Create the highlight
|
||||
highlight_name = make_highlight_name(rgb_hex, mode)
|
||||
if mode == "foreground" then
|
||||
set_highlight(0, highlight_name, { fg = "#" .. rgb_hex })
|
||||
else
|
||||
local rr, gg, bb = rgb_hex:sub(1, 2), rgb_hex:sub(3, 4), rgb_hex:sub(5, 6)
|
||||
local r, g, b = tonumber(rr, 16), tonumber(gg, 16), tonumber(bb, 16)
|
||||
local fg_color
|
||||
if color_is_bright(r, g, b) then
|
||||
fg_color = "Black"
|
||||
else
|
||||
fg_color = "White"
|
||||
end
|
||||
set_highlight(0, highlight_name, { fg = fg_color, bg = "#" .. rgb_hex })
|
||||
end
|
||||
HIGHLIGHT_CACHE[cache_key] = highlight_name
|
||||
return highlight_name
|
||||
end
|
||||
|
||||
--- Create highlight and set highlights
|
||||
---@param buf number
|
||||
---@param ns number
|
||||
---@param line_start number
|
||||
---@param line_end number
|
||||
---@param data table: table output of `parse_lines`
|
||||
---@param options table: Passed in setup, mainly for `user_default_options`
|
||||
function buffer.add_highlight(buf, ns, line_start, line_end, data, options)
|
||||
clear_namespace(buf, ns, line_start, line_end)
|
||||
|
||||
local mode = options.mode == "background" and "background" or "foreground"
|
||||
if vim.tbl_contains({ "foreground", "background" }, options.mode) then
|
||||
for linenr, hls in pairs(data) do
|
||||
for _, hl in ipairs(hls) do
|
||||
local hlname = create_highlight(hl.rgb_hex, mode)
|
||||
api.nvim_buf_add_highlight(buf, ns, hlname, linenr, hl.range[1], hl.range[2])
|
||||
end
|
||||
end
|
||||
elseif options.mode == "virtualtext" then
|
||||
for linenr, hls in pairs(data) do
|
||||
for _, hl in ipairs(hls) do
|
||||
local hlname = create_highlight(hl.rgb_hex, mode)
|
||||
buf_set_virtual_text(buf, ns, linenr, hl.range[2], {
|
||||
end_col = hl.range[2],
|
||||
virt_text = { { options.virtualtext or "■", hlname } },
|
||||
hl_mode = "combine",
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--- Highlight the buffer region.
|
||||
-- Highlight starting from `line_start` (0-indexed) for each line described by `lines` in the
|
||||
-- buffer `buf` and attach it to the namespace `ns`.
|
||||
---@param buf number: buffer id
|
||||
---@param ns number: The namespace id. Default is DEFAULT_NAMESPACE. Create it with `vim.api.nvim_create_namespace`
|
||||
---@param line_start number: line_start should be 0-indexed
|
||||
---@param line_end number: Last line to highlight
|
||||
---@param options table: Configuration options as described in `setup`
|
||||
---@param options_local table: Buffer local variables
|
||||
---@return nil|boolean|number,table
|
||||
function buffer.highlight(buf, ns, line_start, line_end, options, options_local)
|
||||
local returns = { detach = { ns = {}, functions = {} } }
|
||||
if buf == 0 or buf == nil then
|
||||
buf = api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
local lines = buf_get_lines(buf, line_start, line_end, false)
|
||||
|
||||
ns = ns or buffer.default_namespace
|
||||
|
||||
-- only update sass varibles when text is changed
|
||||
if options_local.__event ~= "WinScrolled" and options.sass and options.sass.enable then
|
||||
table.insert(returns.detach.functions, sass_cleanup)
|
||||
sass_update_variables(buf, 0, -1, nil, make_matcher(options.sass.parsers), options, options_local)
|
||||
end
|
||||
|
||||
local data = buffer.parse_lines(buf, lines, line_start, options) or {}
|
||||
buffer.add_highlight(buf, ns, line_start, line_end, data, options)
|
||||
|
||||
if options.tailwind == "lsp" or options.tailwind == "both" then
|
||||
tailwind_setup_lsp(buf, options, options_local, buffer.add_highlight)
|
||||
table.insert(returns.detach.functions, tailwind_cleanup)
|
||||
end
|
||||
|
||||
return true, returns
|
||||
end
|
||||
|
||||
--- Parse the given lines for colors and return a table containing
|
||||
-- rgb_hex and range per line
|
||||
---@param buf number
|
||||
---@param lines table
|
||||
---@param line_start number: This is the buffer line number, from where to start highlighting
|
||||
---@param options table: Passed in `colorizer.setup`, Only uses `user_default_options`
|
||||
---@return table|nil
|
||||
function buffer.parse_lines(buf, lines, line_start, options)
|
||||
local loop_parse_fn = make_matcher(options)
|
||||
if not loop_parse_fn then
|
||||
return
|
||||
end
|
||||
|
||||
local data = {}
|
||||
for current_linenum, line in ipairs(lines) do
|
||||
current_linenum = current_linenum - 1 + line_start
|
||||
data[current_linenum] = data[current_linenum] or {}
|
||||
|
||||
-- Upvalues are options and current_linenum
|
||||
local i = 1
|
||||
while i < #line do
|
||||
local length, rgb_hex = loop_parse_fn(line, i, buf)
|
||||
if length and rgb_hex then
|
||||
table.insert(data[current_linenum], { rgb_hex = rgb_hex, range = { i - 1, i + length - 1 } })
|
||||
i = i + length
|
||||
else
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return data
|
||||
end
|
||||
|
||||
-- gets used in rehighlight function only
|
||||
local BUFFER_LINES = {}
|
||||
-- get the amount lines to highlight
|
||||
local function getrow(buf)
|
||||
if not BUFFER_LINES[buf] then
|
||||
BUFFER_LINES[buf] = {}
|
||||
end
|
||||
|
||||
local a = api.nvim_buf_call(buf, function()
|
||||
---@diagnostic disable-next-line: redundant-return-value
|
||||
return {
|
||||
vim.fn.line "w0",
|
||||
vim.fn.line "w$",
|
||||
}
|
||||
end)
|
||||
local min, max
|
||||
local new_min, new_max = a[1] - 1, a[2]
|
||||
local old_min, old_max = BUFFER_LINES[buf]["min"], BUFFER_LINES[buf]["max"]
|
||||
|
||||
if old_min and old_max then
|
||||
-- Triggered for TextChanged autocmds
|
||||
-- TODO: Find a way to just apply highlight to changed text lines
|
||||
if (old_max == new_max) or (old_min == new_min) then
|
||||
min, max = new_min, new_max
|
||||
-- Triggered for WinScrolled autocmd - Scroll Down
|
||||
elseif old_max < new_max then
|
||||
min = old_max
|
||||
max = new_max
|
||||
-- Triggered for WinScrolled autocmd - Scroll Up
|
||||
elseif old_max > new_max then
|
||||
min = new_min
|
||||
max = new_min + (old_max - new_max)
|
||||
end
|
||||
-- just in case a long jump was made
|
||||
if max - min > new_max - new_min then
|
||||
min = new_min
|
||||
max = new_max
|
||||
end
|
||||
end
|
||||
min = min or new_min
|
||||
max = max or new_max
|
||||
-- store current window position to be used later to incremently highlight
|
||||
BUFFER_LINES[buf]["max"] = new_max
|
||||
BUFFER_LINES[buf]["min"] = new_min
|
||||
return min, max
|
||||
end
|
||||
|
||||
--- Rehighlight the buffer if colorizer is active
|
||||
---@param buf number: Buffer number
|
||||
---@param options table: Buffer options
|
||||
---@param options_local table|nil: Buffer local variables
|
||||
---@param use_local_lines boolean|nil Whether to use lines num range from options_local
|
||||
---@return nil|boolean|number,table
|
||||
function buffer.rehighlight(buf, options, options_local, use_local_lines)
|
||||
if buf == 0 or buf == nil then
|
||||
buf = api.nvim_get_current_buf()
|
||||
end
|
||||
|
||||
local ns = buffer.default_namespace
|
||||
|
||||
local min, max
|
||||
if use_local_lines and options_local then
|
||||
min, max = options_local.__startline or 0, options_local.__endline or -1
|
||||
else
|
||||
min, max = getrow(buf)
|
||||
end
|
||||
|
||||
local bool, returns = buffer.highlight(buf, ns, min, max, options, options_local or {})
|
||||
table.insert(returns.detach.functions, function()
|
||||
BUFFER_LINES[buf] = nil
|
||||
end)
|
||||
|
||||
return bool, returns
|
||||
end
|
||||
|
||||
return buffer
|
||||
@ -1,72 +0,0 @@
|
||||
---Helper color functions
|
||||
--@module colorizer.color
|
||||
local color = {}
|
||||
|
||||
--- Converts an HSL color value to RGB.
|
||||
---@param h number: Hue
|
||||
---@param s number: Saturation
|
||||
---@param l number: Lightness
|
||||
---@return number|nil,number|nil,number|nil
|
||||
function color.hsl_to_rgb(h, s, l)
|
||||
if h > 1 or s > 1 or l > 1 then
|
||||
return
|
||||
end
|
||||
if s == 0 then
|
||||
local r = l * 255
|
||||
return r, r, r
|
||||
end
|
||||
local q
|
||||
if l < 0.5 then
|
||||
q = l * (1 + s)
|
||||
else
|
||||
q = l + s - l * s
|
||||
end
|
||||
local p = 2 * l - q
|
||||
return 255 * color.hue_to_rgb(p, q, h + 1 / 3),
|
||||
255 * color.hue_to_rgb(p, q, h),
|
||||
255 * color.hue_to_rgb(p, q, h - 1 / 3)
|
||||
end
|
||||
|
||||
---Convert hsl colour values to rgb.
|
||||
-- Source: https://gist.github.com/mjackson/5311256
|
||||
---@param p number
|
||||
---@param q number
|
||||
---@param t number
|
||||
---@return number
|
||||
function color.hue_to_rgb(p, q, t)
|
||||
if t < 0 then
|
||||
t = t + 1
|
||||
end
|
||||
if t > 1 then
|
||||
t = t - 1
|
||||
end
|
||||
if t < 1 / 6 then
|
||||
return p + (q - p) * 6 * t
|
||||
end
|
||||
if t < 1 / 2 then
|
||||
return q
|
||||
end
|
||||
if t < 2 / 3 then
|
||||
return p + (q - p) * (2 / 3 - t) * 6
|
||||
end
|
||||
return p
|
||||
end
|
||||
|
||||
---Determine whether to use black or white text.
|
||||
--
|
||||
-- ref: https://stackoverflow.com/a/1855903/837964
|
||||
-- https://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
|
||||
---@param r number: Red
|
||||
---@param g number: Green
|
||||
---@param b number: Blue
|
||||
function color.is_bright(r, g, b)
|
||||
-- counting the perceptive luminance - human eye favors green color
|
||||
local luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255
|
||||
if luminance > 0.5 then
|
||||
return true -- bright colors, black font
|
||||
else
|
||||
return false -- dark colors, white font
|
||||
end
|
||||
end
|
||||
|
||||
return color
|
||||
@ -1,165 +0,0 @@
|
||||
---Helper functions for colorizer to enable required parsers
|
||||
--@module colorizer.matcher
|
||||
local Trie = require "colorizer.trie"
|
||||
local min, max = math.min, math.max
|
||||
|
||||
local color_name_parser = require "colorizer.parser.names"
|
||||
|
||||
local rgb_function_parser = require "colorizer.parser.rgb"
|
||||
local hsl_function_parser = require "colorizer.parser.hsl"
|
||||
|
||||
local argb_hex_parser = require "colorizer.parser.argb_hex"
|
||||
local rgba_hex_parser = require "colorizer.parser.rgba_hex"
|
||||
|
||||
local sass_name_parser = require("colorizer.sass").name_parser
|
||||
|
||||
local B_HASH, DOLLAR_HASH = ("#"):byte(), ("$"):byte()
|
||||
|
||||
local parser = {
|
||||
["_0x"] = argb_hex_parser,
|
||||
["_rgb"] = rgb_function_parser,
|
||||
["_rgba"] = rgb_function_parser,
|
||||
["_hsl"] = hsl_function_parser,
|
||||
["_hsla"] = hsl_function_parser,
|
||||
}
|
||||
|
||||
local matcher = {}
|
||||
|
||||
---Form a trie stuct with the given prefixes
|
||||
---@param matchers table: List of prefixes, {"rgb", "hsl"}
|
||||
---@param matchers_trie table: Table containing information regarding non-trie based parsers
|
||||
---@return function: function which will just parse the line for enabled parsers
|
||||
function matcher.compile(matchers, matchers_trie)
|
||||
local trie = Trie(matchers_trie)
|
||||
|
||||
local function parse_fn(line, i, buf)
|
||||
-- prefix #
|
||||
if matchers.rgba_hex_parser then
|
||||
if line:byte(i) == B_HASH then
|
||||
return rgba_hex_parser(line, i, matchers.rgba_hex_parser)
|
||||
end
|
||||
end
|
||||
|
||||
-- prefix $, SASS Colour names
|
||||
if matchers.sass_name_parser then
|
||||
if line:byte(i) == DOLLAR_HASH then
|
||||
return sass_name_parser(line, i, buf)
|
||||
end
|
||||
end
|
||||
|
||||
-- Prefix 0x, rgba, rgb, hsla, hsl
|
||||
local prefix = trie:longest_prefix(line, i)
|
||||
if prefix then
|
||||
local fn = "_" .. prefix
|
||||
if parser[fn] then
|
||||
return parser[fn](line, i, matchers[prefix])
|
||||
end
|
||||
end
|
||||
|
||||
-- Colour names
|
||||
if matchers.color_name_parser then
|
||||
return color_name_parser(line, i, matchers.color_name_parser)
|
||||
end
|
||||
end
|
||||
return parse_fn
|
||||
end
|
||||
|
||||
local MATCHER_CACHE = {}
|
||||
---Parse the given options and return a function with enabled parsers.
|
||||
--if no parsers enabled then return false
|
||||
--Do not try make the function again if it is present in the cache
|
||||
---@param options table: options created in `colorizer.setup`
|
||||
---@return function|boolean: function which will just parse the line for enabled parsers
|
||||
function matcher.make(options)
|
||||
if not options then
|
||||
return false
|
||||
end
|
||||
|
||||
local enable_names = options.names
|
||||
local enable_sass = options.sass and options.sass.enable
|
||||
local enable_tailwind = options.tailwind
|
||||
local enable_RGB = options.RGB
|
||||
local enable_RRGGBB = options.RRGGBB
|
||||
local enable_RRGGBBAA = options.RRGGBBAA
|
||||
local enable_AARRGGBB = options.AARRGGBB
|
||||
local enable_rgb = options.rgb_fn
|
||||
local enable_hsl = options.hsl_fn
|
||||
|
||||
local matcher_key = 0
|
||||
+ (enable_names and 1 or 0)
|
||||
+ (enable_RGB and 1 or 1)
|
||||
+ (enable_RRGGBB and 1 or 2)
|
||||
+ (enable_RRGGBBAA and 1 or 3)
|
||||
+ (enable_AARRGGBB and 1 or 4)
|
||||
+ (enable_rgb and 1 or 5)
|
||||
+ (enable_hsl and 1 or 6)
|
||||
+ ((enable_tailwind == true or enable_tailwind == "normal") and 1 or 7)
|
||||
+ (enable_tailwind == "lsp" and 1 or 8)
|
||||
+ (enable_tailwind == "both" and 1 or 9)
|
||||
+ (enable_sass and 1 or 10)
|
||||
|
||||
if matcher_key == 0 then
|
||||
return false
|
||||
end
|
||||
|
||||
local loop_parse_fn = MATCHER_CACHE[matcher_key]
|
||||
if loop_parse_fn then
|
||||
return loop_parse_fn
|
||||
end
|
||||
|
||||
local matchers = {}
|
||||
local matchers_prefix = {}
|
||||
matchers.max_prefix_length = 0
|
||||
|
||||
if enable_names then
|
||||
matchers.color_name_parser = { tailwind = options.tailwind }
|
||||
end
|
||||
|
||||
if enable_sass then
|
||||
matchers.sass_name_parser = true
|
||||
end
|
||||
|
||||
local valid_lengths = { [3] = enable_RGB, [6] = enable_RRGGBB, [8] = enable_RRGGBBAA }
|
||||
local minlen, maxlen
|
||||
for k, v in pairs(valid_lengths) do
|
||||
if v then
|
||||
minlen = minlen and min(k, minlen) or k
|
||||
maxlen = maxlen and max(k, maxlen) or k
|
||||
end
|
||||
end
|
||||
|
||||
if minlen then
|
||||
matchers.rgba_hex_parser = {}
|
||||
matchers.rgba_hex_parser.valid_lengths = valid_lengths
|
||||
matchers.rgba_hex_parser.maxlen = maxlen
|
||||
matchers.rgba_hex_parser.minlen = minlen
|
||||
end
|
||||
|
||||
if enable_AARRGGBB then
|
||||
table.insert(matchers_prefix, "0x")
|
||||
end
|
||||
|
||||
if enable_rgb and enable_hsl then
|
||||
table.insert(matchers_prefix, "hsla")
|
||||
table.insert(matchers_prefix, "rgba")
|
||||
table.insert(matchers_prefix, "rgb")
|
||||
table.insert(matchers_prefix, "hsl")
|
||||
elseif enable_rgb then
|
||||
table.insert(matchers_prefix, "rgba")
|
||||
table.insert(matchers_prefix, "rgb")
|
||||
elseif enable_hsl then
|
||||
table.insert(matchers_prefix, "hsla")
|
||||
table.insert(matchers_prefix, "hsl")
|
||||
end
|
||||
|
||||
for _, value in ipairs(matchers_prefix) do
|
||||
matchers[value] = { prefix = value }
|
||||
end
|
||||
|
||||
loop_parse_fn = matcher.compile(matchers, matchers_prefix)
|
||||
MATCHER_CACHE[matcher_key] = loop_parse_fn
|
||||
|
||||
return loop_parse_fn
|
||||
end
|
||||
|
||||
return matcher
|
||||
@ -1,58 +0,0 @@
|
||||
---Helper function to parse argb
|
||||
|
||||
local bit = require "bit"
|
||||
local floor, min = math.floor, math.min
|
||||
local band, rshift, lshift = bit.band, bit.rshift, bit.lshift
|
||||
|
||||
local utils = require "colorizer.utils"
|
||||
local byte_is_alphanumeric = utils.byte_is_alphanumeric
|
||||
local byte_is_hex = utils.byte_is_hex
|
||||
local parse_hex = utils.parse_hex
|
||||
|
||||
local parser = {}
|
||||
|
||||
local ARGB_MINIMUM_LENGTH = #"0xAARRGGBB" - 1
|
||||
---parse for 0xaarrggbb and return rgb hex.
|
||||
-- a format used in android apps
|
||||
---@param line string: line to parse
|
||||
---@param i number: index of line from where to start parsing
|
||||
---@return number|nil: index of line where the hex value ended
|
||||
---@return string|nil: rgb hex value
|
||||
function parser.argb_hex_parser(line, i)
|
||||
if #line < i + ARGB_MINIMUM_LENGTH then
|
||||
return
|
||||
end
|
||||
|
||||
local j = i + 2
|
||||
|
||||
local n = j + 8
|
||||
local alpha
|
||||
local v = 0
|
||||
while j <= min(n, #line) do
|
||||
local b = line:byte(j)
|
||||
if not byte_is_hex(b) then
|
||||
break
|
||||
end
|
||||
if j - i <= 3 then
|
||||
alpha = parse_hex(b) + lshift(alpha or 0, 4)
|
||||
else
|
||||
v = parse_hex(b) + lshift(v, 4)
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
if #line >= j and byte_is_alphanumeric(line:byte(j)) then
|
||||
return
|
||||
end
|
||||
local length = j - i
|
||||
if length ~= 10 then
|
||||
return
|
||||
end
|
||||
alpha = tonumber(alpha) / 255
|
||||
local r = floor(band(rshift(v, 16), 0xFF) * alpha)
|
||||
local g = floor(band(rshift(v, 8), 0xFF) * alpha)
|
||||
local b = floor(band(v, 0xFF) * alpha)
|
||||
local rgb_hex = string.format("%02x%02x%02x", r, g, b)
|
||||
return length, rgb_hex
|
||||
end
|
||||
|
||||
return parser.argb_hex_parser
|
||||
@ -1,110 +0,0 @@
|
||||
---Helper function to parse argb
|
||||
local count = require("colorizer.utils").count
|
||||
local floor = math.floor
|
||||
|
||||
local hsl_to_rgb = require("colorizer.color").hsl_to_rgb
|
||||
|
||||
local parser = {}
|
||||
|
||||
local CSS_HSLA_FN_MINIMUM_LENGTH = #"hsla(0,0%,0%)" - 1
|
||||
local CSS_HSL_FN_MINIMUM_LENGTH = #"hsl(0,0%,0%)" - 1
|
||||
---Parse for hsl() hsla() css function and return rgb hex.
|
||||
-- For more info: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/hsl
|
||||
---@param line string: Line to parse
|
||||
---@param i number: Index of line from where to start parsing
|
||||
---@param opts table: Values passed from matchers like prefix
|
||||
---@return number|nil: Index of line where the hsla/hsl function ended
|
||||
---@return string|nil: rgb hex value
|
||||
function parser.hsl_function_parser(line, i, opts)
|
||||
local min_len = CSS_HSLA_FN_MINIMUM_LENGTH
|
||||
local min_commas, min_spaces = 2, 2
|
||||
local pattern = "^"
|
||||
.. opts.prefix
|
||||
.. "%(%s*([.%d]+)([deg]*)([turn]*)(%s?)%s*(,?)%s*(%d+)%%(%s?)%s*(,?)%s*(%d+)%%%s*(/?,?)%s*([.%d]*)([%%]?)%s*%)()"
|
||||
|
||||
if opts.prefix == "hsl" then
|
||||
min_len = CSS_HSL_FN_MINIMUM_LENGTH
|
||||
end
|
||||
|
||||
if #line < i + min_len then
|
||||
return
|
||||
end
|
||||
|
||||
local h, deg, turn, ssep1, csep1, s, ssep2, csep2, l, sep3, a, percent_sign, match_end = line:sub(i):match(pattern)
|
||||
if not match_end then
|
||||
return
|
||||
end
|
||||
if a == "" then
|
||||
a = nil
|
||||
else
|
||||
min_commas = min_commas + 1
|
||||
end
|
||||
|
||||
-- the text after hue should be either deg or empty
|
||||
if not ((deg == "") or (deg == "deg") or (turn == "turn")) then
|
||||
return
|
||||
end
|
||||
|
||||
local c_seps = ("%s%s%s"):format(csep1, csep2, sep3)
|
||||
local s_seps = ("%s%s"):format(ssep1, ssep2)
|
||||
-- comma separator syntax
|
||||
if c_seps:match "," then
|
||||
if not (count(c_seps, ",") == min_commas) then
|
||||
return
|
||||
end
|
||||
-- space separator syntax with decimal or percentage alpha
|
||||
elseif count(s_seps, "%s") >= min_spaces then
|
||||
if a then
|
||||
if not (c_seps == "/") then
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if not a then
|
||||
a = 1
|
||||
else
|
||||
a = tonumber(a)
|
||||
-- if percentage, then convert to decimal
|
||||
if percent_sign == "%" then
|
||||
a = a / 100
|
||||
end
|
||||
-- although alpha doesn't support larger values than 1, css anyways renders it at 1
|
||||
if a > 1 then
|
||||
a = 1
|
||||
end
|
||||
end
|
||||
|
||||
h = tonumber(h) or 1
|
||||
-- single turn is 360
|
||||
if turn == "turn" then
|
||||
h = 360 * h
|
||||
end
|
||||
|
||||
-- if hue angle if greater than 360, then calculate the hue within 360
|
||||
if h > 360 then
|
||||
local turns = h / 360
|
||||
h = 360 * (turns - floor(turns))
|
||||
end
|
||||
|
||||
-- if saturation or luminance percentage is greater than 100 then reset it to 100
|
||||
s = tonumber(s)
|
||||
if s > 100 then
|
||||
s = 100
|
||||
end
|
||||
l = tonumber(l)
|
||||
if l > 100 then
|
||||
l = 100
|
||||
end
|
||||
|
||||
local r, g, b = hsl_to_rgb(h / 360, s / 100, l / 100)
|
||||
if r == nil or g == nil or b == nil then
|
||||
return
|
||||
end
|
||||
local rgb_hex = string.format("%02x%02x%02x", r * a, g * a, b * a)
|
||||
return match_end - 1, rgb_hex
|
||||
end
|
||||
|
||||
return parser.hsl_function_parser
|
||||
@ -1,84 +0,0 @@
|
||||
---Helper function to parse argb
|
||||
local api = vim.api
|
||||
|
||||
local bit = require "bit"
|
||||
local tohex = bit.tohex
|
||||
|
||||
local min, max = math.min, math.max
|
||||
|
||||
local Trie = require "colorizer.trie"
|
||||
|
||||
local utils = require "colorizer.utils"
|
||||
local byte_is_valid_colorchar = utils.byte_is_valid_colorchar
|
||||
|
||||
local parser = {}
|
||||
|
||||
local COLOR_MAP
|
||||
local COLOR_TRIE
|
||||
local COLOR_NAME_MINLEN, COLOR_NAME_MAXLEN
|
||||
local COLOR_NAME_SETTINGS = { lowercase = true, strip_digits = false }
|
||||
local TAILWIND_ENABLED = false
|
||||
--- Grab all the colour values from `vim.api.nvim_get_color_map` and create a lookup table.
|
||||
-- COLOR_MAP is used to store the colour values
|
||||
---@param line string: Line to parse
|
||||
---@param i number: Index of line from where to start parsing
|
||||
---@param opts table: Currently contains whether tailwind is enabled or not
|
||||
function parser.name_parser(line, i, opts)
|
||||
--- Setup the COLOR_MAP and COLOR_TRIE
|
||||
if not COLOR_TRIE or opts.tailwind ~= TAILWIND_ENABLED then
|
||||
COLOR_MAP = {}
|
||||
COLOR_TRIE = Trie()
|
||||
for k, v in pairs(api.nvim_get_color_map()) do
|
||||
if not (COLOR_NAME_SETTINGS.strip_digits and k:match "%d+$") then
|
||||
COLOR_NAME_MINLEN = COLOR_NAME_MINLEN and min(#k, COLOR_NAME_MINLEN) or #k
|
||||
COLOR_NAME_MAXLEN = COLOR_NAME_MAXLEN and max(#k, COLOR_NAME_MAXLEN) or #k
|
||||
local rgb_hex = tohex(v, 6)
|
||||
COLOR_MAP[k] = rgb_hex
|
||||
COLOR_TRIE:insert(k)
|
||||
if COLOR_NAME_SETTINGS.lowercase then
|
||||
local lowercase = k:lower()
|
||||
COLOR_MAP[lowercase] = rgb_hex
|
||||
COLOR_TRIE:insert(lowercase)
|
||||
end
|
||||
end
|
||||
end
|
||||
if opts and opts.tailwind then
|
||||
if opts.tailwind == true or opts.tailwind == "normal" or opts.tailwind == "both" then
|
||||
local tailwind = require "colorizer.tailwind_colors"
|
||||
-- setup tailwind colors
|
||||
for k, v in pairs(tailwind.colors) do
|
||||
for _, pre in ipairs(tailwind.prefixes) do
|
||||
local name = pre .. "-" .. k
|
||||
COLOR_NAME_MINLEN = COLOR_NAME_MINLEN and min(#name, COLOR_NAME_MINLEN) or #name
|
||||
COLOR_NAME_MAXLEN = COLOR_NAME_MAXLEN and max(#name, COLOR_NAME_MAXLEN) or #name
|
||||
COLOR_MAP[name] = v
|
||||
COLOR_TRIE:insert(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
TAILWIND_ENABLED = opts.tailwind
|
||||
end
|
||||
|
||||
if #line < i + COLOR_NAME_MINLEN - 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if i > 1 and byte_is_valid_colorchar(line:byte(i - 1)) then
|
||||
return
|
||||
end
|
||||
|
||||
local prefix = COLOR_TRIE:longest_prefix(line, i)
|
||||
if prefix then
|
||||
-- Check if there is a letter here so as to disallow matching here.
|
||||
-- Take the Blue out of Blueberry
|
||||
-- Line end or non-letter.
|
||||
local next_byte_index = i + #prefix
|
||||
if #line >= next_byte_index and byte_is_valid_colorchar(line:byte(next_byte_index)) then
|
||||
return
|
||||
end
|
||||
return #prefix, COLOR_MAP[prefix]
|
||||
end
|
||||
end
|
||||
|
||||
return parser.name_parser
|
||||
@ -1,114 +0,0 @@
|
||||
---Helper function to parse argb
|
||||
local count = require("colorizer.utils").count
|
||||
|
||||
local parser = {}
|
||||
local CSS_RGBA_FN_MINIMUM_LENGTH = #"rgba(0,0,0)" - 1
|
||||
local CSS_RGB_FN_MINIMUM_LENGTH = #"rgb(0,0,0)" - 1
|
||||
---Parse for rgb() rgba() css function and return rgb hex.
|
||||
-- For more info: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
|
||||
---@param line string: Line to parse
|
||||
---@param i number: Index of line from where to start parsing
|
||||
---@param opts table: Values passed from matchers like prefix
|
||||
---@return number|nil: Index of line where the rgb/rgba function ended
|
||||
---@return string|nil: rgb hex value
|
||||
function parser.rgb_function_parser(line, i, opts)
|
||||
local min_len = CSS_RGBA_FN_MINIMUM_LENGTH
|
||||
local min_commas, min_spaces, min_percent = 2, 2, 3
|
||||
local pattern = "^"
|
||||
.. opts.prefix
|
||||
.. "%(%s*([.%d]+)([%%]?)(%s?)%s*(,?)%s*([.%d]+)([%%]?)(%s?)%s*(,?)%s*([.%d]+)([%%]?)%s*(/?,?)%s*([.%d]*)([%%]?)%s*%)()"
|
||||
|
||||
if opts.prefix == "rgb" then
|
||||
min_len = CSS_RGB_FN_MINIMUM_LENGTH
|
||||
end
|
||||
|
||||
if #line < i + min_len then
|
||||
return
|
||||
end
|
||||
|
||||
local r, unit1, ssep1, csep1, g, unit2, ssep2, csep2, b, unit3, sep3, a, unit_a, match_end =
|
||||
line:sub(i):match(pattern)
|
||||
if not match_end then
|
||||
return
|
||||
end
|
||||
|
||||
if a == "" then
|
||||
a = nil
|
||||
else
|
||||
min_commas = min_commas + 1
|
||||
end
|
||||
|
||||
local units = ("%s%s%s"):format(unit1, unit2, unit3)
|
||||
if units:match "%%" then
|
||||
if not ((count(units, "%%")) == min_percent) then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
local c_seps = ("%s%s%s"):format(csep1, csep2, sep3)
|
||||
local s_seps = ("%s%s"):format(ssep1, ssep2)
|
||||
-- comma separator syntax
|
||||
if c_seps:match "," then
|
||||
if not (count(c_seps, ",") == min_commas) then
|
||||
return
|
||||
end
|
||||
-- space separator syntax with decimal or percentage alpha
|
||||
elseif count(s_seps, "%s") >= min_spaces then
|
||||
if a then
|
||||
if not (c_seps == "/") then
|
||||
return
|
||||
end
|
||||
end
|
||||
else
|
||||
return
|
||||
end
|
||||
|
||||
if not a then
|
||||
a = 1
|
||||
else
|
||||
a = tonumber(a)
|
||||
-- if percentage, then convert to decimal
|
||||
if unit_a == "%" then
|
||||
a = a / 100
|
||||
end
|
||||
-- although alpha doesn't support larger values than 1, css anyways renders it at 1
|
||||
if a > 1 then
|
||||
a = 1
|
||||
end
|
||||
end
|
||||
|
||||
r = tonumber(r)
|
||||
if not r then
|
||||
return
|
||||
end
|
||||
g = tonumber(g)
|
||||
if not g then
|
||||
return
|
||||
end
|
||||
b = tonumber(b)
|
||||
if not b then
|
||||
return
|
||||
end
|
||||
|
||||
if unit1 == "%" then
|
||||
r = r / 100 * 255
|
||||
g = g / 100 * 255
|
||||
b = b / 100 * 255
|
||||
else
|
||||
-- although r,g,b doesn't support larger values than 255, css anyways renders it at 255
|
||||
if r > 255 then
|
||||
r = 255
|
||||
end
|
||||
if g > 255 then
|
||||
g = 255
|
||||
end
|
||||
if b > 255 then
|
||||
b = 255
|
||||
end
|
||||
end
|
||||
|
||||
local rgb_hex = string.format("%02x%02x%02x", r * a, g * a, b * a)
|
||||
return match_end - 1, rgb_hex
|
||||
end
|
||||
|
||||
return parser.rgb_function_parser
|
||||
@ -1,68 +0,0 @@
|
||||
---Helper function to parse argb
|
||||
local bit = require "bit"
|
||||
local floor, min = math.floor, math.min
|
||||
local band, rshift, lshift = bit.band, bit.rshift, bit.lshift
|
||||
|
||||
local utils = require "colorizer.utils"
|
||||
local byte_is_alphanumeric = utils.byte_is_alphanumeric
|
||||
local byte_is_hex = utils.byte_is_hex
|
||||
local parse_hex = utils.parse_hex
|
||||
|
||||
local parser = {}
|
||||
|
||||
---parse for #rrggbbaa and return rgb hex.
|
||||
-- a format used in android apps
|
||||
---@param line string: line to parse
|
||||
---@param i number: index of line from where to start parsing
|
||||
---@param opts table: Containing minlen, maxlen, valid_lengths
|
||||
---@return number|nil: index of line where the hex value ended
|
||||
---@return string|nil: rgb hex value
|
||||
function parser.rgba_hex_parser(line, i, opts)
|
||||
local minlen, maxlen, valid_lengths = opts.minlen, opts.maxlen, opts.valid_lengths
|
||||
local j = i + 1
|
||||
if #line < j + minlen - 1 then
|
||||
return
|
||||
end
|
||||
|
||||
if i > 1 and byte_is_alphanumeric(line:byte(i - 1)) then
|
||||
return
|
||||
end
|
||||
|
||||
local n = j + maxlen
|
||||
local alpha
|
||||
local v = 0
|
||||
|
||||
while j <= min(n, #line) do
|
||||
local b = line:byte(j)
|
||||
if not byte_is_hex(b) then
|
||||
break
|
||||
end
|
||||
if j - i >= 7 then
|
||||
alpha = parse_hex(b) + lshift(alpha or 0, 4)
|
||||
else
|
||||
v = parse_hex(b) + lshift(v, 4)
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
|
||||
if #line >= j and byte_is_alphanumeric(line:byte(j)) then
|
||||
return
|
||||
end
|
||||
|
||||
local length = j - i
|
||||
if length ~= 4 and length ~= 7 and length ~= 9 then
|
||||
return
|
||||
end
|
||||
|
||||
if alpha then
|
||||
alpha = tonumber(alpha) / 255
|
||||
local r = floor(band(rshift(v, 16), 0xFF) * alpha)
|
||||
local g = floor(band(rshift(v, 8), 0xFF) * alpha)
|
||||
local b = floor(band(v, 0xFF) * alpha)
|
||||
local rgb_hex = string.format("%02x%02x%02x", r, g, b)
|
||||
return 9, rgb_hex
|
||||
end
|
||||
return (valid_lengths[length - 1] and length), line:sub(i + 1, i + length - 1)
|
||||
end
|
||||
|
||||
return parser.rgba_hex_parser
|
||||
@ -1,308 +0,0 @@
|
||||
---Helper functions to parse sass color variables
|
||||
--@module colorizer.sass
|
||||
local api = vim.api
|
||||
local uv = vim.loop
|
||||
|
||||
local utils = require "colorizer.utils"
|
||||
local get_last_modified = utils.get_last_modified
|
||||
local watch_file = utils.watch_file
|
||||
|
||||
local sass = {}
|
||||
|
||||
local DOLLAR_HASH = ("$"):byte()
|
||||
local AT_HASH = ("@"):byte()
|
||||
local COLON_HASH = (";"):byte()
|
||||
|
||||
local SASS = {}
|
||||
|
||||
local function remove_unused_imports(buf, import_name)
|
||||
if type(SASS[buf].IMPORTS[import_name]) == "table" then
|
||||
for file, _ in pairs(SASS[buf].IMPORTS[import_name]) do
|
||||
remove_unused_imports(buf, file)
|
||||
end
|
||||
end
|
||||
SASS[buf].DEFINITIONS[import_name] = nil
|
||||
SASS[buf].DEFINITIONS_LINEWISE[import_name] = nil
|
||||
SASS[buf].IMPORTS[import_name] = nil
|
||||
-- stop the watch handler
|
||||
pcall(uv.fs_event_stop, SASS[buf].WATCH_IMPORTS[import_name])
|
||||
SASS[buf].WATCH_IMPORTS[import_name] = nil
|
||||
end
|
||||
|
||||
--- Cleanup sass variables and watch handlers
|
||||
---@param buf number
|
||||
function sass.cleanup(buf)
|
||||
remove_unused_imports(buf, api.nvim_buf_get_name(buf))
|
||||
SASS[buf] = nil
|
||||
end
|
||||
|
||||
--- Parse the given line for sass color names
|
||||
-- check for value in SASS[buf].DEFINITIONS_ALL
|
||||
---@param line string: Line to parse
|
||||
---@param i number: Index of line from where to start parsing
|
||||
---@param buf number
|
||||
---@return number|nil, string|nil
|
||||
function sass.name_parser(line, i, buf)
|
||||
local variable_name = line:match("^%$([%w_-]+)", i)
|
||||
if variable_name then
|
||||
local rgb_hex = SASS[buf].DEFINITIONS_ALL[variable_name]
|
||||
if rgb_hex then
|
||||
return #variable_name + 1, rgb_hex
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Helper function for sass_update_variables
|
||||
local function sass_parse_lines(buf, line_start, content, name)
|
||||
SASS[buf].DEFINITIONS_ALL = SASS[buf].DEFINITIONS_ALL or {}
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT = SASS[buf].DEFINITIONS_RECURSIVE_CURRENT or {}
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT_ABSOLUTE = SASS[buf].DEFINITIONS_RECURSIVE_CURRENT_ABSOLUTE or {}
|
||||
|
||||
SASS[buf].DEFINITIONS_LINEWISE[name] = SASS[buf].DEFINITIONS_LINEWISE[name] or {}
|
||||
SASS[buf].DEFINITIONS[name] = SASS[buf].DEFINITIONS[name] or {}
|
||||
SASS[buf].IMPORTS[name] = SASS[buf].IMPORTS[name] or {}
|
||||
SASS[buf].WATCH_IMPORTS[name] = SASS[buf].WATCH_IMPORTS[name] or {}
|
||||
SASS[buf].CURRENT_IMPORTS[name] = {}
|
||||
|
||||
local import_find_colon = false
|
||||
for i, line in ipairs(content) do
|
||||
local linenum = i - 1 + line_start
|
||||
-- Invalidate any existing definitions for the lines we are processing.
|
||||
if not vim.tbl_isempty(SASS[buf].DEFINITIONS_LINEWISE[name][linenum] or {}) then
|
||||
for v, _ in pairs(SASS[buf].DEFINITIONS_LINEWISE[name][linenum]) do
|
||||
SASS[buf].DEFINITIONS[name][v] = nil
|
||||
end
|
||||
SASS[buf].DEFINITIONS_LINEWISE[name][linenum] = {}
|
||||
else
|
||||
SASS[buf].DEFINITIONS_LINEWISE[name][linenum] = {}
|
||||
end
|
||||
|
||||
local index = 1
|
||||
while index < #line do
|
||||
-- ignore comments
|
||||
if line:sub(index, index + 1) == "//" then
|
||||
index = #line
|
||||
-- line starting with variables $var
|
||||
elseif not import_find_colon and line:byte(index) == DOLLAR_HASH then
|
||||
local variable_name, variable_value = line:match("^%$([%w_-]+)%s*:%s*(.+)%s*", index)
|
||||
-- Check if we got a variable definition
|
||||
if variable_name and variable_value then
|
||||
-- Check for a recursive variable definition.
|
||||
if variable_value:byte() == DOLLAR_HASH then
|
||||
local target_variable_name, len = variable_value:match "^%$([%w_-]+)()"
|
||||
if target_variable_name then
|
||||
-- Update the value.
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT[variable_name] = target_variable_name
|
||||
SASS[buf].DEFINITIONS_LINEWISE[name][linenum][variable_name] = true
|
||||
index = index + len
|
||||
end
|
||||
index = index + 1
|
||||
else
|
||||
-- Check for a recursive variable definition.
|
||||
-- If it's not recursive, then just update the value.
|
||||
if SASS[buf].COLOR_PARSER then
|
||||
local length, rgb_hex = SASS[buf].COLOR_PARSER(variable_value, 1)
|
||||
if length and rgb_hex then
|
||||
SASS[buf].DEFINITIONS[name][variable_name] = rgb_hex
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT[variable_name] = rgb_hex
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT_ABSOLUTE[variable_name] = rgb_hex
|
||||
SASS[buf].DEFINITIONS_LINEWISE[name][linenum][variable_name] = true
|
||||
-- added 3 because the color parsers returns 3 less
|
||||
-- todo: need to fix
|
||||
index = index + length + 3
|
||||
end
|
||||
end
|
||||
end
|
||||
index = index + #variable_name
|
||||
end
|
||||
-- color ( ; ) found
|
||||
elseif import_find_colon and line:byte(index) == COLON_HASH then
|
||||
import_find_colon, index = false, index + 1
|
||||
-- imports @import 'somefile'
|
||||
elseif line:byte(index) == AT_HASH or import_find_colon then
|
||||
local variable_value, colon, import_kw
|
||||
if import_find_colon then
|
||||
variable_value, colon = line:match("%s*(.*[^;])%s*([;]?)", index)
|
||||
else
|
||||
import_kw, variable_value, colon = line:match("@(%a+)%s+(.+[^;])%s*([;]?)", index)
|
||||
import_kw = (import_kw == "import" or import_kw == "use")
|
||||
end
|
||||
|
||||
if not colon or colon == "" then
|
||||
-- now loop until ; is found
|
||||
import_find_colon = true
|
||||
else
|
||||
import_find_colon = false
|
||||
end
|
||||
|
||||
-- if import/use key word is found along with file name
|
||||
if import_kw and variable_value then
|
||||
local files = {}
|
||||
-- grab files to be imported
|
||||
for s, a in variable_value:gmatch "['\"](.-)()['\"]" do
|
||||
local folder_path, file_name = vim.fn.fnamemodify(s, ":h"), vim.fn.fnamemodify(s, ":t")
|
||||
if file_name ~= "" then
|
||||
-- get the root directory of the file
|
||||
local parent_dir = vim.fn.fnamemodify(name, ":h")
|
||||
parent_dir = (parent_dir ~= "") and parent_dir .. "/" or ""
|
||||
folder_path = vim.fn.fnamemodify(parent_dir .. folder_path, ":p")
|
||||
file_name = file_name
|
||||
table.insert(files, folder_path .. file_name .. ".scss")
|
||||
table.insert(files, folder_path .. "_" .. file_name .. ".scss")
|
||||
table.insert(files, folder_path .. file_name .. ".sass")
|
||||
table.insert(files, folder_path .. "_" .. file_name .. ".sass")
|
||||
end
|
||||
-- why 2 * a ? I don't know
|
||||
index = index + 2 * a
|
||||
end
|
||||
|
||||
-- process imported files
|
||||
for _, v in ipairs(files) do
|
||||
-- parse the sass files
|
||||
local last_modified = get_last_modified(v)
|
||||
if last_modified then
|
||||
-- grab the full path
|
||||
v = uv.fs_realpath(v)
|
||||
SASS[buf].CURRENT_IMPORTS[name][v or ""] = true
|
||||
|
||||
if not SASS[buf].WATCH_IMPORTS[name][v] then
|
||||
SASS[buf].IMPORTS[name][v or ""] = last_modified
|
||||
local c, ind = {}, 0
|
||||
for l in io.lines(v) do
|
||||
ind = ind + 1
|
||||
c[ind] = l
|
||||
end
|
||||
sass_parse_lines(buf, 0, c, v)
|
||||
c = nil
|
||||
|
||||
local function watch_callback()
|
||||
local dimen = vim.api.nvim_buf_call(buf, function()
|
||||
---@diagnostic disable-next-line: redundant-return-value
|
||||
return { vim.fn.line "w0", vim.fn.line "w$", vim.fn.line "$", vim.api.nvim_win_get_height(0) }
|
||||
end)
|
||||
-- todo: Improve this to only refresh highlight for visible lines
|
||||
-- can't find out how to get visible rows from another window
|
||||
-- probably a neovim bug, it is returning 1 and 1 or 1 and 5
|
||||
if
|
||||
SASS[buf].LOCAL_OPTIONS
|
||||
and dimen[1] ~= dimen[2]
|
||||
and ((dimen[3] > dimen[4] and dimen[2] > dimen[4]) or (dimen[2] >= dimen[3]))
|
||||
then
|
||||
SASS[buf].LOCAL_OPTIONS.__startline = dimen[1]
|
||||
SASS[buf].LOCAL_OPTIONS.__endline = dimen[2]
|
||||
end
|
||||
SASS[buf].LOCAL_OPTIONS.__event = ""
|
||||
|
||||
local lastm = get_last_modified(v)
|
||||
if lastm then
|
||||
SASS[buf].IMPORTS[name] = SASS[buf].IMPORTS[name] or {}
|
||||
SASS[buf].IMPORTS[name][v] = lastm
|
||||
local cc, inde = {}, 0
|
||||
for l in io.lines(v) do
|
||||
inde = inde + 1
|
||||
cc[inde] = l
|
||||
end
|
||||
sass_parse_lines(buf, 0, cc, v)
|
||||
cc = nil
|
||||
end
|
||||
|
||||
require("colorizer.buffer").rehighlight(buf, SASS[buf].OPTIONS, SASS[buf].LOCAL_OPTIONS, true)
|
||||
end
|
||||
SASS[buf].WATCH_IMPORTS[name][v] = watch_file(v, watch_callback)
|
||||
end
|
||||
else
|
||||
-- if file does not exists then remove related variables
|
||||
SASS[buf].IMPORTS[name][v] = nil
|
||||
pcall(uv.fs_event_stop, SASS[buf].WATCH_IMPORTS[name][v])
|
||||
SASS[buf].WATCH_IMPORTS[name][v] = nil
|
||||
end
|
||||
end -- process imported files
|
||||
end
|
||||
end -- parse lines
|
||||
index = index + 1
|
||||
end -- while loop end
|
||||
end -- for loop end
|
||||
|
||||
-- remove definitions of files which are not imported now
|
||||
for file, _ in pairs(SASS[buf].IMPORTS[name]) do
|
||||
if not SASS[buf].CURRENT_IMPORTS[name][file] then
|
||||
remove_unused_imports(buf, name)
|
||||
end
|
||||
end
|
||||
end -- sass_parse_lines end
|
||||
|
||||
--- Parse the given lines for sass variabled and add to `SASS[buf].DEFINITIONS_ALL`.
|
||||
-- which is then used in |sass_name_parser|
|
||||
-- If lines are not given, then fetch the lines with line_start and line_end
|
||||
---@param buf number
|
||||
---@param line_start number
|
||||
---@param line_end number
|
||||
---@param lines table|nil
|
||||
---@param color_parser function|boolean
|
||||
---@param options table: Buffer options
|
||||
---@param options_local table|nil: Buffer local variables
|
||||
function sass.update_variables(buf, line_start, line_end, lines, color_parser, options, options_local)
|
||||
lines = lines or vim.api.nvim_buf_get_lines(buf, line_start, line_end, false)
|
||||
|
||||
if not SASS[buf] then
|
||||
SASS[buf] = {
|
||||
DEFINITIONS_ALL = {},
|
||||
DEFINITIONS = {},
|
||||
IMPORTS = {},
|
||||
WATCH_IMPORTS = {},
|
||||
CURRENT_IMPORTS = {},
|
||||
DEFINITIONS_LINEWISE = {},
|
||||
OPTIONS = options,
|
||||
LOCAL_OPTIONS = options_local,
|
||||
}
|
||||
end
|
||||
|
||||
SASS[buf].COLOR_PARSER = color_parser
|
||||
SASS[buf].DEFINITIONS_ALL = {}
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT = {}
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT_ABSOLUTE = {}
|
||||
|
||||
sass_parse_lines(buf, line_start, lines, api.nvim_buf_get_name(buf))
|
||||
|
||||
-- add non-recursive def to DEFINITIONS_ALL
|
||||
for _, color_table in pairs(SASS[buf].DEFINITIONS) do
|
||||
for color_name, color in pairs(color_table) do
|
||||
SASS[buf].DEFINITIONS_ALL[color_name] = color
|
||||
end
|
||||
end
|
||||
|
||||
-- normally this is just a wasted step as all the values here are
|
||||
-- already present in SASS[buf].DEFINITIONS
|
||||
-- but when undoing a pasted text, it acts as a backup
|
||||
for name, color in pairs(SASS[buf].DEFINITIONS_RECURSIVE_CURRENT_ABSOLUTE) do
|
||||
SASS[buf].DEFINITIONS_ALL[name] = color
|
||||
end
|
||||
|
||||
-- try to find the absolute color value for the given name
|
||||
-- use tail call recursion
|
||||
-- https://www.lua.org/pil/6.3.html
|
||||
local function find_absolute_value(name, color_name)
|
||||
return SASS[buf].DEFINITIONS_ALL[color_name]
|
||||
or (
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT[color_name]
|
||||
and find_absolute_value(name, SASS[buf].DEFINITIONS_RECURSIVE_CURRENT[color_name])
|
||||
)
|
||||
end
|
||||
|
||||
local function set_color_value(name, color_name)
|
||||
local value = find_absolute_value(name, color_name)
|
||||
if value then
|
||||
SASS[buf].DEFINITIONS_ALL[name] = value
|
||||
end
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT[name] = nil
|
||||
end
|
||||
|
||||
for name, color_name in pairs(SASS[buf].DEFINITIONS_RECURSIVE_CURRENT) do
|
||||
set_color_value(name, color_name)
|
||||
end
|
||||
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT = nil
|
||||
SASS[buf].DEFINITIONS_RECURSIVE_CURRENT_ABSOLUTE = nil
|
||||
end
|
||||
|
||||
return sass
|
||||
@ -1,161 +0,0 @@
|
||||
---Helper functions to parse tailwind color variables
|
||||
--@module colorizer.tailwind
|
||||
local api = vim.api
|
||||
|
||||
local tailwind = {}
|
||||
|
||||
-- use a different namespace for tailwind as will be cleared if kept in Default namespace
|
||||
local DEFAULT_NAMESPACE_TAILWIND = api.nvim_create_namespace "colorizer_tailwind"
|
||||
|
||||
local TAILWIND = {}
|
||||
|
||||
--- Cleanup tailwind variables and autocmd
|
||||
---@param buf number
|
||||
function tailwind.cleanup(buf)
|
||||
if TAILWIND[buf] and TAILWIND[buf].AU_ID and TAILWIND[buf].AU_ID[1] then
|
||||
pcall(api.nvim_del_autocmd, TAILWIND[buf].AU_ID[1])
|
||||
pcall(api.nvim_del_autocmd, TAILWIND[buf].AU_ID[2])
|
||||
end
|
||||
api.nvim_buf_clear_namespace(buf, DEFAULT_NAMESPACE_TAILWIND, 0, -1)
|
||||
TAILWIND[buf] = nil
|
||||
end
|
||||
|
||||
local function highlight_tailwind(buf, ns, options, add_highlight)
|
||||
-- it can take some time to actually fetch the results
|
||||
-- on top of that, tailwindcss is quite slow in neovim
|
||||
vim.defer_fn(function()
|
||||
if not TAILWIND[buf] or not TAILWIND[buf].CLIENT or not TAILWIND[buf].CLIENT.request then
|
||||
return
|
||||
end
|
||||
|
||||
local opts = { textDocument = vim.lsp.util.make_text_document_params() }
|
||||
--@local
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
TAILWIND[buf].CLIENT.request("textDocument/documentColor", opts, function(err, results, _, _)
|
||||
if err == nil and results ~= nil then
|
||||
local data, line_start, line_end = {}, nil, nil
|
||||
for _, color in pairs(results) do
|
||||
local cur_line = color.range.start.line
|
||||
if line_start then
|
||||
if cur_line < line_start then
|
||||
line_start = cur_line
|
||||
end
|
||||
else
|
||||
line_start = cur_line
|
||||
end
|
||||
|
||||
local end_line = color.range["end"].line
|
||||
if line_end then
|
||||
if end_line > line_end then
|
||||
line_end = end_line
|
||||
end
|
||||
else
|
||||
line_end = end_line
|
||||
end
|
||||
|
||||
local r, g, b, a = color.color.red or 0, color.color.green or 0, color.color.blue or 0, color.color.alpha or 0
|
||||
local rgb_hex = string.format("%02x%02x%02x", r * a * 255, g * a * 255, b * a * 255)
|
||||
local first_col = color.range.start.character
|
||||
local end_col = color.range["end"].character
|
||||
|
||||
data[cur_line] = data[cur_line] or {}
|
||||
table.insert(data[cur_line], { rgb_hex = rgb_hex, range = { first_col, end_col } })
|
||||
end
|
||||
add_highlight(buf, ns, line_start or 0, line_end and (line_end + 2) or -1, data, options)
|
||||
end
|
||||
end)
|
||||
end, 10)
|
||||
end
|
||||
|
||||
--- highlight buffer using values returned by tailwindcss
|
||||
-- To see these table information, see |colorizer.buffer|
|
||||
---@param buf number
|
||||
---@param options table
|
||||
---@param options_local table
|
||||
---@param add_highlight function
|
||||
function tailwind.setup_lsp_colors(buf, options, options_local, add_highlight)
|
||||
TAILWIND[buf] = TAILWIND[buf] or {}
|
||||
TAILWIND[buf].AU_ID = TAILWIND[buf].AU_ID or {}
|
||||
|
||||
if not TAILWIND[buf].CLIENT or TAILWIND[buf].CLIENT.is_stopped() then
|
||||
if vim.version().minor >= 8 then
|
||||
-- create the autocmds so tailwind colours only activate when tailwindcss lsp is active
|
||||
if not TAILWIND[buf].AU_CREATED then
|
||||
api.nvim_buf_clear_namespace(buf, DEFAULT_NAMESPACE_TAILWIND, 0, -1)
|
||||
TAILWIND[buf].AU_ID[1] = api.nvim_create_autocmd("LspAttach", {
|
||||
group = options_local.__augroup_id,
|
||||
buffer = buf,
|
||||
callback = function(args)
|
||||
local ok, client = pcall(vim.lsp.get_client_by_id, args.data.client_id)
|
||||
if ok then
|
||||
if client.name == "tailwindcss" and client.supports_method "textDocument/documentColor" then
|
||||
-- wait 100 ms for the first request
|
||||
TAILWIND[buf].CLIENT = client
|
||||
vim.defer_fn(function()
|
||||
highlight_tailwind(buf, DEFAULT_NAMESPACE_TAILWIND, options, add_highlight)
|
||||
end, 100)
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
-- make sure the autocmds are deleted after lsp server is closed
|
||||
TAILWIND[buf].AU_ID[2] = api.nvim_create_autocmd("LspDetach", {
|
||||
group = options_local.__augroup_id,
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
tailwind.cleanup(buf)
|
||||
end,
|
||||
})
|
||||
TAILWIND[buf].AU_CREATED = true
|
||||
end
|
||||
end
|
||||
-- this will be triggered when no lsp is attached
|
||||
api.nvim_buf_clear_namespace(buf, DEFAULT_NAMESPACE_TAILWIND, 0, -1)
|
||||
|
||||
TAILWIND[buf].CLIENT = nil
|
||||
|
||||
local ok, tailwind_client = pcall(function()
|
||||
return vim.lsp.get_active_clients { bufnr = buf, name = "tailwindcss" }
|
||||
end)
|
||||
if not ok then
|
||||
return
|
||||
end
|
||||
|
||||
ok = false
|
||||
for _, cl in pairs(tailwind_client) do
|
||||
if cl["name"] == "tailwindcss" then
|
||||
tailwind_client = cl
|
||||
ok = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if
|
||||
not ok
|
||||
and (
|
||||
vim.tbl_isempty(tailwind_client or {})
|
||||
or not tailwind_client
|
||||
or not tailwind_client.supports_method
|
||||
or not tailwind_client.supports_method "textDocument/documentColor"
|
||||
)
|
||||
then
|
||||
return true
|
||||
end
|
||||
|
||||
TAILWIND[buf].CLIENT = tailwind_client
|
||||
|
||||
-- wait 500 ms for the first request
|
||||
vim.defer_fn(function()
|
||||
highlight_tailwind(buf, DEFAULT_NAMESPACE_TAILWIND, options, add_highlight)
|
||||
end, 1000)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
-- only try to do tailwindcss highlight if lsp is attached
|
||||
if TAILWIND[buf].CLIENT then
|
||||
highlight_tailwind(buf, DEFAULT_NAMESPACE_TAILWIND, options, add_highlight)
|
||||
end
|
||||
end
|
||||
|
||||
return tailwind
|
||||
@ -1,272 +0,0 @@
|
||||
-- Tailwind colors
|
||||
return {
|
||||
-- https://github.com/tailwindlabs/tailwindcss/raw/master/src/corePlugins.js
|
||||
prefixes = {
|
||||
"accent",
|
||||
"bg",
|
||||
"border",
|
||||
"border-x",
|
||||
"border-y",
|
||||
"border-t",
|
||||
"border-r",
|
||||
"border-b",
|
||||
"border-l",
|
||||
"caret",
|
||||
"decoration",
|
||||
"divide",
|
||||
"fill",
|
||||
"from",
|
||||
"shadow",
|
||||
"stroke",
|
||||
"text",
|
||||
"to",
|
||||
"via",
|
||||
},
|
||||
-- Generated using https://github.com/tailwindlabs/tailwindcss/raw/master/src/public/colors.js
|
||||
colors = {
|
||||
["black"] = "000",
|
||||
["white"] = "fff",
|
||||
["slate-50"] = "f8fafc",
|
||||
["slate-100"] = "f1f5f9",
|
||||
["slate-200"] = "e2e8f0",
|
||||
["slate-300"] = "cbd5e1",
|
||||
["slate-400"] = "94a3b8",
|
||||
["slate-500"] = "64748b",
|
||||
["slate-600"] = "475569",
|
||||
["slate-700"] = "334155",
|
||||
["slate-800"] = "1e293b",
|
||||
["slate-900"] = "0f172a",
|
||||
["slate-950"] = "020617",
|
||||
["gray-50"] = "f9fafb",
|
||||
["gray-100"] = "f3f4f6",
|
||||
["gray-200"] = "e5e7eb",
|
||||
["gray-300"] = "d1d5db",
|
||||
["gray-400"] = "9ca3af",
|
||||
["gray-500"] = "6b7280",
|
||||
["gray-600"] = "4b5563",
|
||||
["gray-700"] = "374151",
|
||||
["gray-800"] = "1f2937",
|
||||
["gray-900"] = "111827",
|
||||
["gray-950"] = "030712",
|
||||
["zinc-50"] = "fafafa",
|
||||
["zinc-100"] = "f4f4f5",
|
||||
["zinc-200"] = "e4e4e7",
|
||||
["zinc-300"] = "d4d4d8",
|
||||
["zinc-400"] = "a1a1aa",
|
||||
["zinc-500"] = "71717a",
|
||||
["zinc-600"] = "52525b",
|
||||
["zinc-700"] = "3f3f46",
|
||||
["zinc-800"] = "27272a",
|
||||
["zinc-900"] = "18181b",
|
||||
["zinc-950"] = "09090b",
|
||||
["neutral-50"] = "fafafa",
|
||||
["neutral-100"] = "f5f5f5",
|
||||
["neutral-200"] = "e5e5e5",
|
||||
["neutral-300"] = "d4d4d4",
|
||||
["neutral-400"] = "a3a3a3",
|
||||
["neutral-500"] = "737373",
|
||||
["neutral-600"] = "525252",
|
||||
["neutral-700"] = "404040",
|
||||
["neutral-800"] = "262626",
|
||||
["neutral-900"] = "171717",
|
||||
["neutral-950"] = "0a0a0a",
|
||||
["stone-50"] = "fafaf9",
|
||||
["stone-100"] = "f5f5f4",
|
||||
["stone-200"] = "e7e5e4",
|
||||
["stone-300"] = "d6d3d1",
|
||||
["stone-400"] = "a8a29e",
|
||||
["stone-500"] = "78716c",
|
||||
["stone-600"] = "57534e",
|
||||
["stone-700"] = "44403c",
|
||||
["stone-800"] = "292524",
|
||||
["stone-900"] = "1c1917",
|
||||
["stone-950"] = "0c0a09",
|
||||
["red-50"] = "fef2f2",
|
||||
["red-100"] = "fee2e2",
|
||||
["red-200"] = "fecaca",
|
||||
["red-300"] = "fca5a5",
|
||||
["red-400"] = "f87171",
|
||||
["red-500"] = "ef4444",
|
||||
["red-600"] = "dc2626",
|
||||
["red-700"] = "b91c1c",
|
||||
["red-800"] = "991b1b",
|
||||
["red-900"] = "7f1d1d",
|
||||
["red-950"] = "450a0a",
|
||||
["orange-50"] = "fff7ed",
|
||||
["orange-100"] = "ffedd5",
|
||||
["orange-200"] = "fed7aa",
|
||||
["orange-300"] = "fdba74",
|
||||
["orange-400"] = "fb923c",
|
||||
["orange-500"] = "f97316",
|
||||
["orange-600"] = "ea580c",
|
||||
["orange-700"] = "c2410c",
|
||||
["orange-800"] = "9a3412",
|
||||
["orange-900"] = "7c2d12",
|
||||
["orange-950"] = "431407",
|
||||
["amber-50"] = "fffbeb",
|
||||
["amber-100"] = "fef3c7",
|
||||
["amber-200"] = "fde68a",
|
||||
["amber-300"] = "fcd34d",
|
||||
["amber-400"] = "fbbf24",
|
||||
["amber-500"] = "f59e0b",
|
||||
["amber-600"] = "d97706",
|
||||
["amber-700"] = "b45309",
|
||||
["amber-800"] = "92400e",
|
||||
["amber-900"] = "78350f",
|
||||
["amber-950"] = "451a03",
|
||||
["yellow-50"] = "fefce8",
|
||||
["yellow-100"] = "fef9c3",
|
||||
["yellow-200"] = "fef08a",
|
||||
["yellow-300"] = "fde047",
|
||||
["yellow-400"] = "facc15",
|
||||
["yellow-500"] = "eab308",
|
||||
["yellow-600"] = "ca8a04",
|
||||
["yellow-700"] = "a16207",
|
||||
["yellow-800"] = "854d0e",
|
||||
["yellow-900"] = "713f12",
|
||||
["yellow-950"] = "422006",
|
||||
["lime-50"] = "f7fee7",
|
||||
["lime-100"] = "ecfccb",
|
||||
["lime-200"] = "d9f99d",
|
||||
["lime-300"] = "bef264",
|
||||
["lime-400"] = "a3e635",
|
||||
["lime-500"] = "84cc16",
|
||||
["lime-600"] = "65a30d",
|
||||
["lime-700"] = "4d7c0f",
|
||||
["lime-800"] = "3f6212",
|
||||
["lime-900"] = "365314",
|
||||
["lime-950"] = "1a2e05",
|
||||
["green-50"] = "f0fdf4",
|
||||
["green-100"] = "dcfce7",
|
||||
["green-200"] = "bbf7d0",
|
||||
["green-300"] = "86efac",
|
||||
["green-400"] = "4ade80",
|
||||
["green-500"] = "22c55e",
|
||||
["green-600"] = "16a34a",
|
||||
["green-700"] = "15803d",
|
||||
["green-800"] = "166534",
|
||||
["green-900"] = "14532d",
|
||||
["green-950"] = "052e16",
|
||||
["emerald-50"] = "ecfdf5",
|
||||
["emerald-100"] = "d1fae5",
|
||||
["emerald-200"] = "a7f3d0",
|
||||
["emerald-300"] = "6ee7b7",
|
||||
["emerald-400"] = "34d399",
|
||||
["emerald-500"] = "10b981",
|
||||
["emerald-600"] = "059669",
|
||||
["emerald-700"] = "047857",
|
||||
["emerald-800"] = "065f46",
|
||||
["emerald-900"] = "064e3b",
|
||||
["emerald-950"] = "022c22",
|
||||
["teal-50"] = "f0fdfa",
|
||||
["teal-100"] = "ccfbf1",
|
||||
["teal-200"] = "99f6e4",
|
||||
["teal-300"] = "5eead4",
|
||||
["teal-400"] = "2dd4bf",
|
||||
["teal-500"] = "14b8a6",
|
||||
["teal-600"] = "0d9488",
|
||||
["teal-700"] = "0f766e",
|
||||
["teal-800"] = "115e59",
|
||||
["teal-900"] = "134e4a",
|
||||
["teal-950"] = "042f2e",
|
||||
["cyan-50"] = "ecfeff",
|
||||
["cyan-100"] = "cffafe",
|
||||
["cyan-200"] = "a5f3fc",
|
||||
["cyan-300"] = "67e8f9",
|
||||
["cyan-400"] = "22d3ee",
|
||||
["cyan-500"] = "06b6d4",
|
||||
["cyan-600"] = "0891b2",
|
||||
["cyan-700"] = "0e7490",
|
||||
["cyan-800"] = "155e75",
|
||||
["cyan-900"] = "164e63",
|
||||
["cyan-950"] = "083344",
|
||||
["sky-50"] = "f0f9ff",
|
||||
["sky-100"] = "e0f2fe",
|
||||
["sky-200"] = "bae6fd",
|
||||
["sky-300"] = "7dd3fc",
|
||||
["sky-400"] = "38bdf8",
|
||||
["sky-500"] = "0ea5e9",
|
||||
["sky-600"] = "0284c7",
|
||||
["sky-700"] = "0369a1",
|
||||
["sky-800"] = "075985",
|
||||
["sky-900"] = "0c4a6e",
|
||||
["sky-950"] = "082f49",
|
||||
["blue-50"] = "eff6ff",
|
||||
["blue-100"] = "dbeafe",
|
||||
["blue-200"] = "bfdbfe",
|
||||
["blue-300"] = "93c5fd",
|
||||
["blue-400"] = "60a5fa",
|
||||
["blue-500"] = "3b82f6",
|
||||
["blue-600"] = "2563eb",
|
||||
["blue-700"] = "1d4ed8",
|
||||
["blue-800"] = "1e40af",
|
||||
["blue-900"] = "1e3a8a",
|
||||
["blue-950"] = "172554",
|
||||
["indigo-50"] = "eef2ff",
|
||||
["indigo-100"] = "e0e7ff",
|
||||
["indigo-200"] = "c7d2fe",
|
||||
["indigo-300"] = "a5b4fc",
|
||||
["indigo-400"] = "818cf8",
|
||||
["indigo-500"] = "6366f1",
|
||||
["indigo-600"] = "4f46e5",
|
||||
["indigo-700"] = "4338ca",
|
||||
["indigo-800"] = "3730a3",
|
||||
["indigo-900"] = "312e81",
|
||||
["indigo-950"] = "1e1b4b",
|
||||
["violet-50"] = "f5f3ff",
|
||||
["violet-100"] = "ede9fe",
|
||||
["violet-200"] = "ddd6fe",
|
||||
["violet-300"] = "c4b5fd",
|
||||
["violet-400"] = "a78bfa",
|
||||
["violet-500"] = "8b5cf6",
|
||||
["violet-600"] = "7c3aed",
|
||||
["violet-700"] = "6d28d9",
|
||||
["violet-800"] = "5b21b6",
|
||||
["violet-900"] = "4c1d95",
|
||||
["violet-950"] = "2e1065",
|
||||
["purple-50"] = "faf5ff",
|
||||
["purple-100"] = "f3e8ff",
|
||||
["purple-200"] = "e9d5ff",
|
||||
["purple-300"] = "d8b4fe",
|
||||
["purple-400"] = "c084fc",
|
||||
["purple-500"] = "a855f7",
|
||||
["purple-600"] = "9333ea",
|
||||
["purple-700"] = "7e22ce",
|
||||
["purple-800"] = "6b21a8",
|
||||
["purple-900"] = "581c87",
|
||||
["purple-950"] = "3b0764",
|
||||
["fuchsia-50"] = "fdf4ff",
|
||||
["fuchsia-100"] = "fae8ff",
|
||||
["fuchsia-200"] = "f5d0fe",
|
||||
["fuchsia-300"] = "f0abfc",
|
||||
["fuchsia-400"] = "e879f9",
|
||||
["fuchsia-500"] = "d946ef",
|
||||
["fuchsia-600"] = "c026d3",
|
||||
["fuchsia-700"] = "a21caf",
|
||||
["fuchsia-800"] = "86198f",
|
||||
["fuchsia-900"] = "701a75",
|
||||
["fuchsia-950"] = "4a044e",
|
||||
["pink-50"] = "fdf2f8",
|
||||
["pink-100"] = "fce7f3",
|
||||
["pink-200"] = "fbcfe8",
|
||||
["pink-300"] = "f9a8d4",
|
||||
["pink-400"] = "f472b6",
|
||||
["pink-500"] = "ec4899",
|
||||
["pink-600"] = "db2777",
|
||||
["pink-700"] = "be185d",
|
||||
["pink-800"] = "9d174d",
|
||||
["pink-900"] = "831843",
|
||||
["pink-950"] = "500724",
|
||||
["rose-50"] = "fff1f2",
|
||||
["rose-100"] = "ffe4e6",
|
||||
["rose-200"] = "fecdd3",
|
||||
["rose-300"] = "fda4af",
|
||||
["rose-400"] = "fb7185",
|
||||
["rose-500"] = "f43f5e",
|
||||
["rose-600"] = "e11d48",
|
||||
["rose-700"] = "be123c",
|
||||
["rose-800"] = "9f1239",
|
||||
["rose-900"] = "881337",
|
||||
["rose-950"] = "4c0519"
|
||||
},
|
||||
}
|
||||
@ -1,262 +0,0 @@
|
||||
---Trie implementation in luajit.
|
||||
--todo: write documentation
|
||||
|
||||
-- Copyright © 2019 Ashkan Kiani
|
||||
-- This program is free software: you can redistribute it and/or modify
|
||||
-- it under the terms of the GNU General Public License as published by
|
||||
-- the Free Software Foundation, either version 3 of the License, or
|
||||
-- (at your option) any later version.
|
||||
--
|
||||
-- This program is distributed in the hope that it will be useful,
|
||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
-- GNU General Public License for more details.
|
||||
--
|
||||
-- You should have received a copy of the GNU General Public License
|
||||
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
--@module trie
|
||||
local ffi = require "ffi"
|
||||
|
||||
ffi.cdef [[
|
||||
struct Trie {
|
||||
bool is_leaf;
|
||||
struct Trie* character[62];
|
||||
};
|
||||
void *malloc(size_t size);
|
||||
void free(void *ptr);
|
||||
]]
|
||||
|
||||
local Trie_t = ffi.typeof "struct Trie"
|
||||
local Trie_ptr_t = ffi.typeof("$ *", Trie_t)
|
||||
local Trie_size = ffi.sizeof(Trie_t)
|
||||
|
||||
local function trie_create()
|
||||
local ptr = ffi.C.malloc(Trie_size)
|
||||
ffi.fill(ptr, Trie_size)
|
||||
return ffi.cast(Trie_ptr_t, ptr)
|
||||
end
|
||||
|
||||
local function trie_destroy(trie)
|
||||
if trie == nil then
|
||||
return
|
||||
end
|
||||
for i = 0, 61 do
|
||||
local child = trie.character[i]
|
||||
if child ~= nil then
|
||||
trie_destroy(child)
|
||||
end
|
||||
end
|
||||
ffi.C.free(trie)
|
||||
end
|
||||
|
||||
local total_char = 255
|
||||
local INDEX_LOOKUP_TABLE = ffi.new("uint8_t[?]", total_char)
|
||||
local CHAR_LOOKUP_TABLE = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-"
|
||||
do
|
||||
local b = string.byte
|
||||
local extra_char = {
|
||||
[b "-"] = true,
|
||||
}
|
||||
local byte = { ["0"] = b "0", ["9"] = b "9", ["a"] = b "a", ["A"] = b "A", ["z"] = b "z", ["Z"] = b "Z" }
|
||||
for i = 0, total_char do
|
||||
if i >= byte["0"] and i <= byte["9"] then
|
||||
INDEX_LOOKUP_TABLE[i] = i - byte["0"]
|
||||
elseif i >= byte["A"] and i <= byte["Z"] then
|
||||
INDEX_LOOKUP_TABLE[i] = i - byte["A"] + 10
|
||||
elseif i >= byte["a"] and i <= byte["z"] then
|
||||
INDEX_LOOKUP_TABLE[i] = i - byte["a"] + 10 + 26
|
||||
elseif extra_char[i] then
|
||||
else
|
||||
INDEX_LOOKUP_TABLE[i] = total_char
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function trie_insert(trie, value)
|
||||
if trie == nil then
|
||||
return false
|
||||
end
|
||||
local node = trie
|
||||
for i = 1, #value do
|
||||
local index = INDEX_LOOKUP_TABLE[value:byte(i)]
|
||||
if index == total_char then
|
||||
return false
|
||||
end
|
||||
if node.character[index] == nil then
|
||||
node.character[index] = trie_create()
|
||||
end
|
||||
node = node.character[index]
|
||||
end
|
||||
node.is_leaf = true
|
||||
return node, trie
|
||||
end
|
||||
|
||||
local function trie_search(trie, value, start)
|
||||
if trie == nil then
|
||||
return false
|
||||
end
|
||||
local node = trie
|
||||
for i = (start or 1), #value do
|
||||
local index = INDEX_LOOKUP_TABLE[value:byte(i)]
|
||||
if index == total_char then
|
||||
return
|
||||
end
|
||||
local child = node.character[index]
|
||||
if child == nil then
|
||||
return false
|
||||
end
|
||||
node = child
|
||||
end
|
||||
return node.is_leaf
|
||||
end
|
||||
|
||||
local function trie_longest_prefix(trie, value, start, exact)
|
||||
if trie == nil then
|
||||
return false
|
||||
end
|
||||
-- insensitive = insensitive and 0x20 or 0
|
||||
start = start or 1
|
||||
local node = trie
|
||||
local last_i = nil
|
||||
for i = start, #value do
|
||||
local index = INDEX_LOOKUP_TABLE[value:byte(i)]
|
||||
-- local index = INDEX_LOOKUP_TABLE[bor(insensitive, value:byte(i))]
|
||||
if index == total_char then
|
||||
break
|
||||
end
|
||||
local child = node.character[index]
|
||||
if child == nil then
|
||||
break
|
||||
end
|
||||
if child.is_leaf then
|
||||
last_i = i
|
||||
end
|
||||
node = child
|
||||
end
|
||||
if last_i then
|
||||
-- Avoid a copy if the whole string is a match.
|
||||
if start == 1 and last_i == #value then
|
||||
return value
|
||||
end
|
||||
|
||||
if not exact then
|
||||
return value:sub(start, last_i)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function trie_extend(trie, t)
|
||||
assert(type(t) == "table")
|
||||
for _, v in ipairs(t) do
|
||||
trie_insert(trie, v)
|
||||
end
|
||||
end
|
||||
|
||||
--- Printing utilities
|
||||
|
||||
local function index_to_char(index)
|
||||
if index < 0 or index > 61 then
|
||||
return
|
||||
end
|
||||
return CHAR_LOOKUP_TABLE:sub(index + 1, index + 1)
|
||||
end
|
||||
|
||||
local function trie_as_table(trie)
|
||||
if trie == nil then
|
||||
return nil
|
||||
end
|
||||
local children = {}
|
||||
for i = 0, 61 do
|
||||
local child = trie.character[i]
|
||||
if child ~= nil then
|
||||
local child_table = trie_as_table(child)
|
||||
child_table.c = index_to_char(i)
|
||||
table.insert(children, child_table)
|
||||
end
|
||||
end
|
||||
return {
|
||||
is_leaf = trie.is_leaf,
|
||||
children = children,
|
||||
}
|
||||
end
|
||||
|
||||
local function print_trie_table(s)
|
||||
local mark
|
||||
if not s then
|
||||
return { "nil" }
|
||||
end
|
||||
if s.c then
|
||||
if s.is_leaf then
|
||||
mark = s.c .. "*"
|
||||
else
|
||||
mark = s.c .. "─"
|
||||
end
|
||||
else
|
||||
mark = "├─"
|
||||
end
|
||||
if #s.children == 0 then
|
||||
return { mark }
|
||||
end
|
||||
local lines = {}
|
||||
for _, child in ipairs(s.children) do
|
||||
local child_lines = print_trie_table(child)
|
||||
for _, child_line in ipairs(child_lines) do
|
||||
table.insert(lines, child_line)
|
||||
end
|
||||
end
|
||||
local child_count = 0
|
||||
for i, line in ipairs(lines) do
|
||||
local line_parts = {}
|
||||
if line:match "^%w" then
|
||||
child_count = child_count + 1
|
||||
if i == 1 then
|
||||
line_parts = { mark }
|
||||
elseif i == #lines or child_count == #s.children then
|
||||
line_parts = { "└─" }
|
||||
else
|
||||
line_parts = { "├─" }
|
||||
end
|
||||
else
|
||||
if i == 1 then
|
||||
line_parts = { mark }
|
||||
elseif #s.children > 1 and child_count ~= #s.children then
|
||||
line_parts = { "│ " }
|
||||
else
|
||||
line_parts = { " " }
|
||||
end
|
||||
end
|
||||
table.insert(line_parts, line)
|
||||
lines[i] = table.concat(line_parts)
|
||||
end
|
||||
return lines
|
||||
end
|
||||
|
||||
local function trie_to_string(trie)
|
||||
if trie == nil then
|
||||
return "nil"
|
||||
end
|
||||
local as_table = trie_as_table(trie)
|
||||
return table.concat(print_trie_table(as_table), "\n")
|
||||
end
|
||||
|
||||
local Trie_mt = {
|
||||
__new = function(_, init)
|
||||
local trie = trie_create()
|
||||
if type(init) == "table" then
|
||||
trie_extend(trie, init)
|
||||
end
|
||||
return trie
|
||||
end,
|
||||
__index = {
|
||||
insert = trie_insert,
|
||||
search = trie_search,
|
||||
longest_prefix = trie_longest_prefix,
|
||||
extend = trie_extend,
|
||||
destroy = trie_destroy,
|
||||
},
|
||||
__tostring = trie_to_string,
|
||||
__gc = trie_destroy,
|
||||
}
|
||||
|
||||
return ffi.metatype("struct Trie", Trie_mt)
|
||||
@ -1,169 +0,0 @@
|
||||
---Helper utils
|
||||
--@module colorizer.utils
|
||||
local bit, ffi = require "bit", require "ffi"
|
||||
local band, bor, rshift, lshift = bit.band, bit.bor, bit.rshift, bit.lshift
|
||||
|
||||
local uv = vim.loop
|
||||
|
||||
local utils = {}
|
||||
|
||||
-- -- TODO use rgb as the return value from the matcher functions
|
||||
-- -- instead of the rgb_hex. Can be the highlight key as well
|
||||
-- -- when you shift it left 8 bits. Use the lower 8 bits for
|
||||
-- -- indicating which highlight mode to use.
|
||||
-- ffi.cdef [[
|
||||
-- typedef struct { uint8_t r, g, b; } colorizer_rgb;
|
||||
-- ]]
|
||||
-- local rgb_t = ffi.typeof 'colorizer_rgb'
|
||||
|
||||
-- Create a lookup table where the bottom 4 bits are used to indicate the
|
||||
-- category and the top 4 bits are the hex value of the ASCII byte.
|
||||
local BYTE_CATEGORY = ffi.new "uint8_t[256]"
|
||||
local CATEGORY_DIGIT = lshift(1, 0)
|
||||
local CATEGORY_ALPHA = lshift(1, 1)
|
||||
local CATEGORY_HEX = lshift(1, 2)
|
||||
local CATEGORY_ALPHANUM = bor(CATEGORY_ALPHA, CATEGORY_DIGIT)
|
||||
|
||||
do
|
||||
-- do not run the loop multiple times
|
||||
local b = string.byte
|
||||
local byte_values = { ["0"] = b "0", ["9"] = b "9", ["a"] = b "a", ["f"] = b "f", ["z"] = b "z" }
|
||||
|
||||
for i = 0, 255 do
|
||||
local v = 0
|
||||
local lowercase = bor(i, 0x20)
|
||||
-- Digit is bit 1
|
||||
if i >= byte_values["0"] and i <= byte_values["9"] then
|
||||
v = bor(v, lshift(1, 0))
|
||||
v = bor(v, lshift(1, 2))
|
||||
v = bor(v, lshift(i - byte_values["0"], 4))
|
||||
elseif lowercase >= byte_values["a"] and lowercase <= byte_values["z"] then
|
||||
-- Alpha is bit 2
|
||||
v = bor(v, lshift(1, 1))
|
||||
if lowercase <= byte_values["f"] then
|
||||
v = bor(v, lshift(1, 2))
|
||||
v = bor(v, lshift(lowercase - byte_values["a"] + 10, 4))
|
||||
end
|
||||
end
|
||||
BYTE_CATEGORY[i] = v
|
||||
end
|
||||
end
|
||||
|
||||
---Obvious.
|
||||
---@param byte number
|
||||
---@return boolean
|
||||
function utils.byte_is_alphanumeric(byte)
|
||||
local category = BYTE_CATEGORY[byte]
|
||||
return band(category, CATEGORY_ALPHANUM) ~= 0
|
||||
end
|
||||
|
||||
---Obvious.
|
||||
---@param byte number
|
||||
---@return boolean
|
||||
function utils.byte_is_hex(byte)
|
||||
return band(BYTE_CATEGORY[byte], CATEGORY_HEX) ~= 0
|
||||
end
|
||||
|
||||
---Valid colorchars are alphanumeric and - ( tailwind colors )
|
||||
---@param byte number
|
||||
---@return boolean
|
||||
function utils.byte_is_valid_colorchar(byte)
|
||||
return utils.byte_is_alphanumeric(byte) or byte == ("-"):byte()
|
||||
end
|
||||
|
||||
---Count the number of character in a string
|
||||
---@param str string
|
||||
---@param pattern string
|
||||
---@return number
|
||||
function utils.count(str, pattern)
|
||||
return select(2, string.gsub(str, pattern, ""))
|
||||
end
|
||||
|
||||
--- Get last modified time of a file
|
||||
---@param path string: file path
|
||||
---@return number|nil: modified time
|
||||
function utils.get_last_modified(path)
|
||||
local fd = uv.fs_open(path, "r", 438)
|
||||
if not fd then
|
||||
return
|
||||
end
|
||||
|
||||
local stat = uv.fs_fstat(fd)
|
||||
uv.fs_close(fd)
|
||||
if stat then
|
||||
return stat.mtime.nsec
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
---Merge two tables.
|
||||
--
|
||||
-- todo: Remove this and use `vim.tbl_deep_extend`
|
||||
---@return table
|
||||
function utils.merge(...)
|
||||
local res = {}
|
||||
for i = 1, select("#", ...) do
|
||||
local o = select(i, ...)
|
||||
if type(o) ~= "table" then
|
||||
return {}
|
||||
end
|
||||
for k, v in pairs(o) do
|
||||
res[k] = v
|
||||
end
|
||||
end
|
||||
return res
|
||||
end
|
||||
|
||||
--- Obvious.
|
||||
---@param byte number
|
||||
---@return number
|
||||
function utils.parse_hex(byte)
|
||||
return rshift(BYTE_CATEGORY[byte], 4)
|
||||
end
|
||||
|
||||
--- Watch a file for changes and execute callback
|
||||
---@param path string: File path
|
||||
---@param callback function: Callback to execute
|
||||
---@param ... table: params for callback
|
||||
---@return function|nil
|
||||
function utils.watch_file(path, callback, ...)
|
||||
if not path or type(callback) ~= "function" then
|
||||
return
|
||||
end
|
||||
|
||||
local fullpath = uv.fs_realpath(path)
|
||||
if not fullpath then
|
||||
return
|
||||
end
|
||||
|
||||
local start
|
||||
local args = { ... }
|
||||
|
||||
local handle = uv.new_fs_event()
|
||||
local function on_change(err, filename, _)
|
||||
-- Do work...
|
||||
callback(filename, unpack(args))
|
||||
-- Debounce: stop/start.
|
||||
handle:stop()
|
||||
if not err or not utils.get_last_modified(filename) then
|
||||
start()
|
||||
end
|
||||
end
|
||||
|
||||
function start()
|
||||
uv.fs_event_start(
|
||||
handle,
|
||||
fullpath,
|
||||
{},
|
||||
vim.schedule_wrap(function(...)
|
||||
on_change(...)
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
start()
|
||||
return handle
|
||||
end
|
||||
|
||||
return utils
|
||||
@ -1,29 +0,0 @@
|
||||
if vim.g.loaded_colorizer then
|
||||
return
|
||||
end
|
||||
|
||||
local command = vim.api.nvim_create_user_command
|
||||
|
||||
command("ColorizerAttachToBuffer", function()
|
||||
require("colorizer").attach_to_buffer(0)
|
||||
end, {})
|
||||
|
||||
-- Stop highlighting the current buffer (detach).
|
||||
command("ColorizerDetachFromBuffer", function()
|
||||
require("colorizer").detach_from_buffer(0)
|
||||
end, {})
|
||||
|
||||
command("ColorizerReloadAllBuffers", function()
|
||||
require("colorizer").reload_all_buffers()
|
||||
end, {})
|
||||
|
||||
command("ColorizerToggle", function()
|
||||
local c = require "colorizer"
|
||||
if c.is_buffer_attached(0) then
|
||||
c.detach_from_buffer(0)
|
||||
else
|
||||
c.attach_to_buffer(0)
|
||||
end
|
||||
end, {})
|
||||
|
||||
vim.g.loaded_colorizer = true
|
||||
@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
create_vim_doc() (
|
||||
local project_name="${1:?}"
|
||||
local target="${2:?}"
|
||||
local template="${3:?}"
|
||||
local cur_dir
|
||||
cur_dir="$(pwd)"
|
||||
|
||||
if [[ -d "${target}" ]]; then
|
||||
cp "${template}" "${TMP_DIR}/ldoc.ltp" || return 1
|
||||
else
|
||||
echo "No such template exists"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -d "${target}" ]]; then
|
||||
ldoc -p "${project_name}" -t "${project_name} Docs" -u "${target}" -l "${TMP_DIR}" -d "${TMP_DIR}" --date "- $(date +'%B')" || cleanup
|
||||
cd "${TMP_DIR}/modules" || exit 1
|
||||
cat "${project_name}".html "${project_name}"*.*.html >"${project_name}".txt || cleanup
|
||||
elif [[ -f "${target}" ]]; then
|
||||
ldoc -p "${project_name}" -t "${project_name} Docs" -u "${target}" -l "${TMP_DIR}" -d "${TMP_DIR}" --date "- $(date +'%B')" || cleanup
|
||||
cd "${TMP_DIR}" || exit 1
|
||||
cat index.html >"${project_name}".txt || cleanup
|
||||
else
|
||||
echo "Invalid target"
|
||||
return 1
|
||||
fi
|
||||
echo "vim:tw=80:ts=8:noet:ft=help:norl:" >>"${project_name}".txt
|
||||
# format each line to be within 80 columns
|
||||
# replace <pre> and </pre> with > and < respectively
|
||||
# Sometimes running the command one time is not enough, reason unknown
|
||||
nvim --headless +"set tw=80" \
|
||||
+'%norm gqq' \
|
||||
+'%norm gqq' \
|
||||
+'%s/<pre>/>/g' \
|
||||
+'%s/<\/pre>/</g' \
|
||||
"${project_name}".txt \
|
||||
+"wqa" || {
|
||||
echo "Coundn't format with nvim, but help file be placed"
|
||||
}
|
||||
mkdir -p "${cur_dir}/doc"
|
||||
cp "${project_name}".txt "${cur_dir}/doc/${project_name}.txt" || cleanup
|
||||
echo
|
||||
echo "${cur_dir}/doc/${project_name}.txt" created
|
||||
|
||||
return 0
|
||||
)
|
||||
|
||||
main() {
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
|
||||
cleanup() { rm -rf "${TMP_DIR}" exit 0; }
|
||||
|
||||
project_name="colorizer"
|
||||
if command -v ldoc 1>/dev/null; then
|
||||
# html docs
|
||||
ldoc -f discount -p "${project_name}" -t "${project_name} Docs" -u lua "${@}" -s doc --date "- $(date +'%B')" || cleanup
|
||||
|
||||
# vim docs
|
||||
create_vim_doc "${project_name}" lua doc/ldoc_vim.ltp || cleanup
|
||||
else
|
||||
echo "Error: Install ldoc first"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
}
|
||||
|
||||
main "${@}"
|
||||
@ -1,51 +0,0 @@
|
||||
-- vim:ft=lua
|
||||
require("colorizer").detach_from_buffer(0)
|
||||
require("colorizer").attach_to_buffer(0, { AARRGGBB = true, css = true, mode = "foreground" })
|
||||
--[[ SUCCESS
|
||||
0xFf32A14B 0xFf32A14B
|
||||
#32a14b
|
||||
|
||||
#F0F #FF00FF #FFF00F8F #F0F #FF00FF
|
||||
#FF32A14B
|
||||
#FFF00F8F
|
||||
#F0F #F00
|
||||
#FF00FF #F00
|
||||
#FFF00F8F #F00
|
||||
|
||||
blue gray lightblue gray100 white gold blue
|
||||
Blue LightBlue Gray100 White
|
||||
White
|
||||
|
||||
#def #deadbeef
|
||||
|
||||
rgb( 31 12.90 50 /0.5) rgb( 10, 100 , 100, 0.3)
|
||||
rgb(30% 20% 50%) rgb(0,0,0) rgb(255 122 127 / 80%)
|
||||
rgb(255 122 127 / .2) rgba(200,30,0,1) rgba(200,30,0,0.5)
|
||||
|
||||
hsl(300 50% 50%) hsl(300 50% 50% / 1) hsl(100 80% 50% / 0.4)
|
||||
hsl(990 80% 50% / 0.4) hsl(720 80% 50% / 0.4)
|
||||
hsl(1turn 80% 50% / 0.4) hsl(0.4turn 80% 50% / 0.4) hsl(1.4turn 80% 50% / 0.4)
|
||||
hsla(300 50% 50%) hsla(300 50% 50% / 1)
|
||||
hsla(300 50% 50% / 0.4) hsla(300,50%,50%,05)
|
||||
hsla(360 , 50% , 50% , 1.0000000000000001)
|
||||
]]
|
||||
|
||||
--[[ FAIL
|
||||
#---
|
||||
#F0FF
|
||||
#F0FFF
|
||||
#F0FFF0F
|
||||
#F0FFF0FFF
|
||||
Blueberry Gray1000 BlueGree BlueGray
|
||||
#define
|
||||
#def0
|
||||
matcher#add
|
||||
rgb (10,255,100)
|
||||
rgb(10, 1 00 , 100)
|
||||
hsl(300 50% 50% 1)
|
||||
hsl(300 50% 50 / 1)
|
||||
hsla(10 10% 10% 1)
|
||||
hsla(300,50%,50,1.0000000000000001)
|
||||
hsla(300,50,50,1.0000000000000001)
|
||||
hsla(361,50,50,1.0000000000000001)
|
||||
]]
|
||||
@ -1,53 +0,0 @@
|
||||
local Trie = require "colorizer.trie"
|
||||
local color_map = vim.api.nvim_get_color_map
|
||||
|
||||
local function print_color_trie()
|
||||
local tohex = bit.tohex
|
||||
local min, max = math.min, math.max
|
||||
|
||||
local COLOR_NAME_SETTINGS = {
|
||||
lowercase = false,
|
||||
strip_digits = true,
|
||||
}
|
||||
local COLOR_MAP = {}
|
||||
local COLOR_TRIE = Trie()
|
||||
for k, v in pairs(color_map()) do
|
||||
if not (COLOR_NAME_SETTINGS.strip_digits and k:match "%d+$") then
|
||||
COLOR_NAME_MINLEN = COLOR_NAME_MINLEN and min(#k, COLOR_NAME_MINLEN) or #k
|
||||
COLOR_NAME_MAXLEN = COLOR_NAME_MAXLEN and max(#k, COLOR_NAME_MAXLEN) or #k
|
||||
COLOR_MAP[k] = tohex(v, 6)
|
||||
COLOR_TRIE:insert(k)
|
||||
if COLOR_NAME_SETTINGS.lowercase then
|
||||
local lowercase = k:lower()
|
||||
COLOR_MAP[lowercase] = tohex(v, 6)
|
||||
COLOR_TRIE:insert(lowercase)
|
||||
end
|
||||
end
|
||||
end
|
||||
print(COLOR_TRIE)
|
||||
end
|
||||
|
||||
local trie = Trie {
|
||||
"cat",
|
||||
"car",
|
||||
"celtic",
|
||||
"carb",
|
||||
"carb0",
|
||||
"CART0",
|
||||
"CaRT0",
|
||||
"Cart0",
|
||||
"931",
|
||||
"191",
|
||||
"121",
|
||||
"cardio",
|
||||
"call",
|
||||
"calcium",
|
||||
"calciur",
|
||||
"carry",
|
||||
"dog",
|
||||
"catdog",
|
||||
}
|
||||
|
||||
print(trie)
|
||||
print("catdo", trie:longest_prefix "catdo")
|
||||
print("catastrophic", trie:longest_prefix "catastrophic")
|
||||
@ -1,30 +0,0 @@
|
||||
@import "scss/colors1";
|
||||
|
||||
// simple variables
|
||||
$test2: hotpink;
|
||||
$test5: rgb(123, 255, 123);
|
||||
$test7: rgba(255, 123, 123, 0.9);
|
||||
|
||||
// reference
|
||||
$dd: $test7;
|
||||
|
||||
// present in colors2.sass which is imported by colors1.sass
|
||||
$test0: $color1;
|
||||
// present in colors1.sass
|
||||
$test1: $color2;
|
||||
|
||||
// recursive definitions
|
||||
$d: $test1;
|
||||
$dark: $d;
|
||||
$e: $dark;
|
||||
$f: $e;
|
||||
$g: $f;
|
||||
|
||||
$test3: $color3;
|
||||
$test4: $color4;
|
||||
$test6: $color6; // this should be absent and this comment shoudl be ignored $color6: black
|
||||
$test8: $color8;
|
||||
$test9: $color9;
|
||||
$test10: $color10;
|
||||
$test11: $color11;
|
||||
$aki: red;
|
||||
@ -1,12 +0,0 @@
|
||||
@import "colors2";
|
||||
|
||||
$color2: #E33224;
|
||||
$color4: rgb(195, 60, 190);
|
||||
|
||||
$color5: $color2;
|
||||
|
||||
$color7: linear-gradient(to left, #0055ff, #7201b2 50%, #f83371);
|
||||
$color8: #ff0;
|
||||
$color9: #B0B;
|
||||
$color10: cornflowerblue;
|
||||
$color11: hsla(120, 60%, 70%, 0.3);
|
||||
@ -1,4 +0,0 @@
|
||||
$color1: #203CDB;
|
||||
$color3: rgb(250, 145, 55);
|
||||
|
||||
$color6: radial-gradient(circle farthest-corner at 32% 106%, rgb(255, 225, 125) 0%, rgb(255, 205, 105) 10%, rgb(250, 145, 55) 28%, rgb(235, 65, 65) 42%, transparent 82%), linear-gradient(135deg, rgb(35, 75, 215) 12%, rgb(195, 60, 190) 58%);
|
||||
Reference in New Issue
Block a user