From e962e74f9749566416585282315256ce403feab1 Mon Sep 17 00:00:00 2001 From: Buliway Date: Thu, 20 Mar 2025 17:05:10 +0300 Subject: [PATCH] Add nvim colorizer --- nvim/init.lua | 3 ++ nvim/lazy-lock.json | 1 + nvim/lua/custom/plugins/colorizer.lua | 63 +++++++++++++++++++++++++++ nvim/lua/custom/sessions.lua | 4 -- 4 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 nvim/lua/custom/plugins/colorizer.lua diff --git a/nvim/init.lua b/nvim/init.lua index 3643f69..cee2f2c 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -91,6 +91,9 @@ require('lazy').setup({ -- Plugins for git require 'custom.plugins.git', + -- Plugins for color highlight + require 'custom.plugins.colorizer', + -- Autoformat markdown tables { 'Kicamon/markdown-table-mode.nvim', diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 286189e..7a186cc 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -34,6 +34,7 @@ "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" }, "nvim-autopairs": { "branch": "master", "commit": "68f0e5c3dab23261a945272032ee6700af86227a" }, "nvim-cmp": { "branch": "main", "commit": "1e1900b0769324a9675ef85b38f99cca29e203b3" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "517df88cf2afb36652830df2c655df2da416a0ae" }, "nvim-dap": { "branch": "master", "commit": "a720d4966f758ab22e8ec28812b6df90a53e0f02" }, "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" }, "nvim-dap-ui": { "branch": "master", "commit": "bc81f8d3440aede116f821114547a476b082b319" }, diff --git a/nvim/lua/custom/plugins/colorizer.lua b/nvim/lua/custom/plugins/colorizer.lua new file mode 100644 index 0000000..5be4349 --- /dev/null +++ b/nvim/lua/custom/plugins/colorizer.lua @@ -0,0 +1,63 @@ +-- A high-performance color highlighter + +return { + { + 'catgoose/nvim-colorizer.lua', + event = 'BufReadPre', + opts = { -- set to setup table + filetypes = { '*' }, -- Filetype options. Accepts table like `user_default_options` + buftypes = {}, -- Buftype options. Accepts table like `user_default_options` + -- Boolean | List of usercommands to enable. See User commands section. + user_commands = true, -- Enable all or some usercommands + lazy_load = false, -- Lazily schedule buffer highlighting setup function + user_default_options = { + names = true, -- "Name" codes like Blue or red. Added from `vim.api.nvim_get_color_map()` + names_opts = { -- options for mutating/filtering names. + lowercase = true, -- name:lower(), highlight `blue` and `red` + camelcase = true, -- name, highlight `Blue` and `Red` + uppercase = false, -- name:upper(), highlight `BLUE` and `RED` + strip_digits = false, -- ignore names with digits, + -- highlight `blue` and `red`, but not `blue3` and `red4` + }, + -- Expects a table of color name to #RRGGBB value pairs. # is optional + -- Example: { cool = "#107dac", ["notcool"] = "ee9240" } + -- Set to false to disable, for example when setting filetype options + names_custom = false, -- Custom names to be highlighted: table|function|false + RGB = true, -- #RGB hex codes + RGBA = true, -- #RGBA hex codes + RRGGBB = true, -- #RRGGBB hex codes + 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*: + -- names, RGB, RGBA, RRGGBB, RRGGBBAA, AARRGGBB, rgb_fn, hsl_fn + css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn + -- Tailwind colors. boolean|'normal'|'lsp'|'both'. True sets to 'normal' + tailwind = false, -- Enable tailwind colors + tailwind_opts = { -- Options for highlighting tailwind names + update_names = false, -- When using tailwind = 'both', update tailwind names from LSP results. See tailwind section + }, + -- parsers can contain values used in `user_default_options` + sass = { enable = false, parsers = { 'css' } }, -- Enable sass colors + -- Highlighting mode. 'background'|'foreground'|'virtualtext' + mode = 'background', -- Set the display mode + -- Virtualtext character to use + virtualtext = '■', + -- Display virtualtext inline with color. boolean|'before'|'after'. True sets to 'after' + virtualtext_inline = false, + -- Virtualtext highlight mode: 'background'|'foreground' + virtualtext_mode = 'foreground', + -- update color values even if buffer is not focused + -- example use: cmp_menu, cmp_docs + always_update = false, + -- hooks to invert control of colorizer + hooks = { + -- called before line parsing. Accepts boolean or function that returns boolean + -- see hooks section below + disable_line_highlight = false, + }, + }, + }, + }, +} diff --git a/nvim/lua/custom/sessions.lua b/nvim/lua/custom/sessions.lua index 82c1416..8ffde53 100644 --- a/nvim/lua/custom/sessions.lua +++ b/nvim/lua/custom/sessions.lua @@ -17,10 +17,6 @@ local function session_name() local branch = get_git_branch() local name = cwd - -- if branch then - -- name = name .. '-' .. branch - -- end - local sha = vim.fn.sha256(name) if branch then