nvim-lualine / lualine.nvim

A blazing fast and easy to configure neovim statusline plugin written in pure lua.
MIT License
5.75k stars 457 forks source link

Typings for LSP #563

Open zorgick opened 2 years ago

zorgick commented 2 years ago

Hi wanted to share my typings for your plugin

---@alias TLualineThemes
---| "auto"
---| "16color"
---| "ayu_dark"
---| "ayu_light"
---| "ayu_mirage"
---| "ayu"
---| "codedark"
---| "dracula"
---| "everforest"
---| "gruvbox_dark"
---| "gruvbox_light"
---| "gruvbox"
---| "gruvbox-material"
---| "horizon"
---| "iceberg_dark"
---| "iceberg_light"
---| "iceberg"
---| "jellybeans"
---| "material"
---| "modus-vivendi"
---| "molokai"
---| "moonfly"
---| "nightfly"
---| "nord"
---| "OceanicNext"
---| "onedark"
---| "onelight"
---| "palenight"
---| "papercolor_dark"
---| "papercolor_light"
---| "PaperColor"
---| "powerline"
---| "powerline_dark"
---| "pywal"
---| "seoul256"
---| "solarized_dark"
---| "solarized_light"
---| "Tomorrow"
---| "wombat"

---@class TLualineOpts
-- Show icons.
-- default: true
---@field icons_enabled boolean
-- Lualine theme name.
-- Auto theme will load the theme automaically for your colorscheme
-- or will generate one otherwise.
-- default: 'auto'
---@field theme TLualineThemes
-- Separators between components.
-- default: { left = '', right = '' }
---@field component_separators table|string
-- Separators between sections.
-- default: { left = '', right = '' }
---@field section_separators table|string
-- Filetypes to disable lualine for.
-- default: {}
---@field disabled_filetypes table
-- When set to true, left sections i.e. 'a','b' and 'c'
-- can't take over the entire statusline even
-- if neither of 'x', 'y' or 'z' are present.
-- default: true
---@field always_divide_middle boolean

---@alias TLualineComponents
---| "branch"
---| "buffers"
---| "diagnostics"
---| "diff"
---| "encoding"
---| "fileformat"
---| "filename"
---| "filesize"
---| "filetype"
---| "hostname"
---| "location"
---| "mode"
---| "progress`"
---| "tabs"

---@class TLualineGeneralComponent
-- Must be written as array value
---@field [1] TLualineComponents
-- Enables the display of icons alongside the component.
-- default: true
---@field icons_enabled boolean
-- Defines the icon to be displayed in front of the component.
-- default: nil
---@field icon string
-- When a string is provided it's treated as component_separator.
-- When a table is provided it's treated as section_separator.
-- Passing an empty string disables the separator.
-- default: nil
---@field separator string|table
-- Condition function, the component is loaded when the function returns `true`.
-- default: nil
---@field cond fun():boolean
-- Defines a custom color for the component.
-- example: { fg = '#ffaa88', bg = 'grey', gui='italic,bold' } | { fg = 204 } | "WarningMsg"
-- default: nil - default to theme color
---@field color string|table
-- Specify what type a component is.
-- default: nil
---@field type string|table
-- Adds padding to the left and right of components.
-- default: 1
---@field padding number
-- Format function, formats the component's output.
-- default: nil
---@field fmt fun():string

---@class TLualineColors
-- Color for active buffer.
-- default: nil
--@field active string|table
-- Color for inactive buffer.
-- default: nil
--@field inactive string|table

---@class TLualineBuffer: TLualineGeneralComponent
-- Shows shortened relative path when set to false.
-- default: true
---@field show_filename_only boolean
-- Shows indicator when the buffer is modified.
-- default: true
---@field show_modified_status boolean
-- 0: Shows buffer name
-- 1: Shows buffer index (bufnr)
-- 2: Shows buffer name + buffer index (bufnr)
-- default: 0
---@field mode number
-- Maximum width of buffers component.
-- default: vim.o.columns * 2 / 3
---@field max_length number|fun():number
-- Shows specific buffer name for that filetype.
-- default: { TelescopePrompt = 'Telescope', dashboard = 'Dashboard', packer = 'Packer', fzf = 'FZF', alpha = 'Alpha' }
---@field filetype_names table
-- Buffers colors
---@field buffers_color TLualineColors

---@class TLualineDiagnosticsColors
-- Diagnostics' error color.
-- default: "DiagnosticError"
---@field error string|table
-- Diagnostics' warn color.
-- default: "DiagnosticWarn"
---@field warn string|table
-- Diagnostics' info color.
-- default: "DiagnosticInfo"
---@field info string|table
-- Diagnostics' hint color.
-- default: "DiagnosticHint"
---@field hint string|table

---@class TLualineDiagnosticsSymbols
-- Diagnostics' error symbol (icons, then no_icons).
-- default: ' ' | "E"
---@field error string
-- Diagnostics' warn symbol (icons, then no_icons).
-- default: ' ' | "W"
---@field warn string
-- Diagnostics' info symbol (icons, then no_icons).
-- default: ' ' | "I"
---@field info string
-- Diagnostics' hint symbol (icons, then no_icons).
-- default: ' ' | "H"
---@field hint string

---@class TLualineDiagnostics: TLualineGeneralComponent
-- Table of diagnostic sources. Possible values:
-- 'nvim_lsp', 'nvim_diagnostic', 'coc', 'ale', 'vim_lsp',
-- fun():{error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt}
-- default: {'nvim_diagnostic' or 'nvim_lsp', 'coc'}
---@field sources string[]|fun():table
-- Displays diagnostics for the defined severity types.
-- default: {'error', 'warn', 'info', 'hint'}
---@field sections string[]
-- Diagnostics colors
---@field diagnostics_color TLualineDiagnosticsColors
-- Diagnostics symbols
---@field symbols TLualineDiagnosticsSymbols
-- Displays diagnostics status in color if set to true.
-- default: true
---@field colored boolean
-- Update diagnostics in insert mode.
-- default: false
---@field update_in_insert boolean
-- Show diagnostics even if there are none.
-- default: false
---@field always_visible boolean

---@class TLualineDiffColors
-- Diff's added color
-- default: "DiffAdd"
---@field added string|table
-- Diff's modified color
-- default: "DiffChange"
---@field modified string|table
-- Diff's removed color
-- default: "DiffDelete"
---@field removed string|table

---@class TLualineDiffSymbols
-- Diff's added symbol
-- default: "+"
---@field added string
-- Diff's modified symbol
-- default: "~"
---@field modified string
-- Diff's removed symbol
-- default: "-"
---@field removed string

---@class TLualineDiff: TLualineGeneralComponent
-- Displays a colored diff status if set to true
-- default: true
---@field colored boolean
-- Diff's colors
---@field diff_color TLualineDiffColors
-- Diff's symbols
---@field symbols TLualineDiffSymbols
-- Function that populates data for the diff
-- fun():{ added = add_count, modified = modified_count, removed = removed_count }
-- default: nil
---@field source fun():table

---@class TLualineFileformat
-- Fileformat symbols
-- default: { unix = '', dos = '', mac = '', }
---@field symbols table

---@class TLualineFilename: TLualineGeneralComponent
-- Displays file status (readonly status, modified status).
-- default: true
---@field file_status boolean
-- 0: Just the filename
-- 1: Relative path
-- 2: Absolute path
-- default: 0
---@field path number
-- Shortens path to leave `n` spaces in the window
-- default: 40
---@field shorting_target number
-- Filename symbols
-- default: { modified = '[+]', readonly = '[-]', unnamed = '[No Name]', }
---@field symbols table

---@class TLualineFiletype: TLualineGeneralComponent
-- Displays filetype icon in color if set to true
-- default: true
---@field colored boolean
-- Display only an icon for filetype
-- default: false
---@field icon_only boolean

---@class TLualineTabs: TLualineGeneralComponent
-- Maximum width of tabs component.
-- default: vim.o.columns * 2 / 3
---@field max_length number|fun():number
-- 0: Shows tab_nr
-- 1: Shows tab_name
-- 2: Shows tab_nr + tab_name
-- default: 0
---@field mode number
-- Tabs colors
---@field tabs_color TLualineColors

---@alias TLualineArrayOfComponents table<number,TLualineGeneralComponent|TLualineBuffer|TLualineDiagnostics|TLualineDiff|TLualineFileformat|TLualineFilename|TLualineFiletype|TLualineTabs>

---@alias TLualineSection string[] | TLualineComponents[] | fun()[] | TLualineArrayOfComponents

---@alias TLualineExtensions
---| "chadtree"
---| "fern"
---| "fugitive"
---| "fzf"
---| "nerdtree"
---| "nvim-tree"
---| "quickfix"
---| "toggleterm"
---| "symbols-outline"

---@alias TLualineSectionGroups table<"lualine_a"|"lualine_b"|"lualine_c"|"lualine_x"|"lualine_y"|"lualine_z"|,TLualineSection>

---@class TLualineConfig
-- Configuration of the lualine behavior.
-- Options here are inherited by all components.
---@field options TLualineOpts
-- Configuration of the status line sections for active buffers.
---@field sections TLualineSectionGroups
-- Configuration of the status line sections for inactive buffers.
---@field inactive_sections TLualineSectionGroups
-- Configuration of the tab line.
---@field tabline TLualineSectionGroups
-- Change statusline appearance for a window/buffer with specified filetypes
---@field extensions TLualineExtensions[]|string[]|table[]
shadmansaleh commented 2 years ago

Thanks for taking your time to make this . TBH I am not sure what I'm looking at . My guess would be lsp will be able to auto complete lualine configuarations with this ? But where does this need to be placed . If you want to add this to the repo I think a pr will be nicer as I have no clue what to do with this :]

zorgick commented 2 years ago

Ok, I will try to push it this evening