aboutsummaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/lushwal.lua
blob: 94c5681627da7cbd7c797880d248ecb4cc7a84ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
local function apply_transparent_overrides()
  local hl = vim.api.nvim_set_hl
  local none = "NONE"
  hl(0, "Normal", { bg = none })
  hl(0, "NormalFloat", { bg = none })
  hl(0, "FloatBorder", { bg = none })
  hl(0, "EndOfBuffer", { bg = none })
  hl(0, "CursorLine", { bg = none })
  hl(0, "LineNr", { bg = none })
  hl(0, "SignColumn", { bg = none })
  hl(0, "Pmenu", { bg = none })
  hl(0, "PmenuSel", { bg = none })
  hl(0, "TelescopeNormal", { bg = none })
  hl(0, "TelescopeBorder", { bg = none })
end

local function set_transparent(on)
  vim.g.lushwal_transparent = on
  if on then
    apply_transparent_overrides()
  else
    -- Restore theme defaults (pywal colors with solid background)
    vim.cmd("colorscheme lushwal")
  end
  vim.notify(
    (on and "Transparency on" or "Transparency off"),
    vim.log.levels.INFO,
    { title = "Lushwal" }
  )
end

local function toggle_transparent()
  set_transparent(vim.g.lushwal_transparent ~= true)
end

return {
  {
    "oncomouse/lushwal.nvim",
    cmd = { "LushwalCompile" },
    dependencies = {
      { "rktjmp/lush.nvim" },
      { "rktjmp/shipwright.nvim" },
    },
    lazy = false,
    init = function()
      -- Solid background by default (pywal colors). Run :LushwalCompile once after this change to regenerate the theme.
      vim.g.lushwal_configuration = {
        transparent_background = false,
      }
    end,
    config = function()
      vim.g.lushwal_transparent = false -- off by default
      vim.api.nvim_create_user_command("LushwalToggleTransparency", toggle_transparent, {})
      vim.keymap.set("n", "<leader>ut", toggle_transparent, { desc = "Toggle transparency" })
      -- Re-apply transparent overrides after colorscheme load when user had transparency on
      vim.api.nvim_create_autocmd("ColorScheme", {
        pattern = "lushwal",
        callback = function()
          if vim.g.lushwal_transparent then
            apply_transparent_overrides()
          else
            -- Softer cursor line so the active line doesn't overpower the text
            vim.api.nvim_set_hl(0, "CursorLine", { bg = "#252530", fg = "NONE" })
          end
        end,
      })
      -- Apply subtle CursorLine on first load (non-transparent default)
      vim.defer_fn(function()
        if vim.g.colors_name == "lushwal" and not vim.g.lushwal_transparent then
          vim.api.nvim_set_hl(0, "CursorLine", { bg = "#252530", fg = "NONE" })
        end
      end, 10)
    end,
  },
  -- Add project.nvim for better project management
  {
    "ahmedkhalf/project.nvim",
    keys = {
      { "<leader>fp", "<Cmd>Telescope projects<CR>", desc = "Find Projects" },
    },
    config = function()
      require("project_nvim").setup({
        -- Path where to store the project history for telescope
        datapath = vim.fn.stdpath("data"),
        -- Detection methods for projects
        detection_methods = { "pattern", "lsp" },
        -- Patterns used to detect projects
        patterns = {
          ".git",
          "_darcs",
          ".hg",
          ".bzr",
          ".svn",
          "Makefile",
          "package.json",
          "Cargo.toml",
          "requirements.txt",
          "pyproject.toml",
          "go.mod",
          "composer.json",
          "Gemfile",
          ".lazy.lua",
        },
        -- Only consider these directories as projects
        scope_chdir = "tab",
        -- What to do when changing project
        silent_chdir = false,
      })
      require("telescope").load_extension("projects")
    end,
  },
  -- Configure LazyVim to load lushwal
  {
    "LazyVim/LazyVim",
    opts = {
      colorscheme = "lushwal",
    },
  },
}