Skip to content

Plugins

Diego Ulloa edited this page May 22, 2024 · 16 revisions

1. lualine

plugins/lualine.lua

-- require custom extensions
local extensions = require("root.extensions.lualine") -- replace root

return {
  "nvim-lualine/lualine.nvim",
  dependencies = {
    "folke/noice.nvim",
    "nvim-tree/nvim-web-devicons",
  },
  config = function()
    -- require noice
    local noice = require("noice")

    -- require lazy extensions
    local lazy_status = require("lazy.status")

    -- custom setup
    require("lualine").setup({
      options = {
        theme = require("neofusion.lualine"),
        globalstatus = true,
        component_separators = { left = "", right = "" },
        section_separators = { left = "", right = "" },
        disabled_filetypes = { "dashboard", "packer", "help" },
        ignore_focus = {}, -- add filetypes inside
      },
      -- man:124 for sections doc
      sections = {
        lualine_a = { "progress" }, -- disable vim mode viewer
        lualine_b = {
          {
            "branch",
            icon = "", -- disable icon
            padding = { left = 1, right = 1 },
          },
        },
        lualine_c = {
          -- filetype icon
          {
            "filetype",
            icon_only = true,
            padding = { left = 2, right = 0 },
            color = "_lualine_c_filetype",
          },
          -- filename
          {
            "filename",
            file_status = true, -- display file status (read only, modified)
            path = 1, -- 0: just name, 1: relative path, 2: absolute path, 3: absolute path with ~ as home directory
            symbols = {
              unnamed = "",
              readonly = "",
              modified = "",
            },
            padding = { left = 1 },
            color = { gui = "bold" },
          },
        },
        lualine_x = {
          {
            lazy_status.updates,
            cond = lazy_status.has_updates,
          },
          -- number of changes in file
          {
            "diff",
            colored = true,
            padding = { right = 2 },
            symbols = {
              added = "+",
              modified = "|",
              removed = "-",
            },
          },
          -- status like @recording
          {
            noice.api.statusline.mode.get,
            cond = noice.api.statusline.mode.has,
          },
        },
        lualine_y = {},
        lualine_z = { "location" },
      },
      extensions = {
        "nvim-tree",
        "toggleterm",
        "mason",
        "fzf",
        "quickfix",
        "man",
        "lazy",
        -- custom extensions
        extensions.telescope,
        extensions.lspinfo,
        extensions.saga,
        extensions.btw,
      },
    })
  end,
}

extensions

extensions/lualine/telescope.lua

-- extension: telescope
local function get_display_name()
  return "Telescope"
end

-- custom extension
local telescope = {
  sections = {
    lualine_a = {
      { get_display_name },
    },
  },
  filetypes = { "TelescopePrompt" },
}

-- export
return telescope

extensions/lualine/lspinfo.lua

-- extension: lsp info
local function get_display_name()
  return "LspInfo"
end

-- custom extension
local lsp_info = {
  sections = {
    lualine_a = {
      { get_display_name },
    },
  },
  filetypes = { "lspinfo" },
}

-- export
return lsp_info

extensions/lualine/saga.lua

-- extension: saga
local function get_display_name()
  local filetype = vim.bo.filetype
  local action = filetype:match("saga(%a+)")

  return "Saga" .. action:gsub("^%l", string.upper)
end

-- custom extension
local saga = {
  sections = {
    lualine_a = {
      { get_display_name },
    },
  },
  filetypes = { "sagaoutline", "sagafinder" },
}

-- export
return saga

extensions/lualine/btw.lua

-- extension: telescope
local function get_display_name()
  return "BTW bitch."
end

-- custom extension
local telescope = {
  sections = {
    lualine_a = {
      { get_display_name },
    },
  },
  filetypes = { "starter" },
}

-- export
return telescope

2. nvim-tree

plugins/nvim-tree.lua

-- recommended settings from nvim-tree documentation
vim.g.loaded = 1
vim.g.loaded_netrwPlugin = 1

-- custom setup
return {
  "nvim-tree/nvim-tree.lua",
  version = "*",
  dependencies = {
    "nvim-tree/nvim-web-devicons",
  },
  opts = {
    view = {
      width = 38,
    },
    renderer = {
      root_folder_label = false, -- hide root directory at the top
      indent_markers = {
        enable = enable, -- folder level guide
        icons = {
          corner = "",
          edge = "",
          item = "",
          bottom = "",
          none = " ",
        },
      },
      icons = {
        glyphs = {
          folder = {
            default = "",
            open = "",
            empty = "",
            empty_open = "",
          },
          git = {
            unstaged = "",
            staged = "",
            unmerged = "",
            renamed = "",
            untracked = "",
            deleted = "",
            ignored = "",
          },
        },
      },
    },
    actions = {
      open_file = {
        quit_on_open = true,
        window_picker = {
          enable = false,
        },
      },
    },
    update_focused_file = {
      enable = true,
      update_root = true,
    },
    filters = {
      dotfiles = true,
    },
    sync_root_with_cwd = true,
    respect_buf_cwd = true,
  },
}
Clone this wiki locally