enhance: set default diagnostics source to nvim-lsp & coc

doc: update docs for options.
This commit is contained in:
shadmansaleh 2021-09-21 12:26:19 +06:00
parent 07d3df01a1
commit ceec01bc6c
5 changed files with 74 additions and 22 deletions

View File

@ -106,7 +106,7 @@ Lualine has sections as shown below.
Each sections holds it's components e.g. current vim's mode.
<details><summary>Configuring from `.vim` file</summary>
<details><summary>Configuring lualine in init.vim</summary>
All the examples below are in lua. You can use the same examples
in `.vim` file by wrapping them in lua heredoc like this:
@ -332,26 +332,40 @@ shown . On the other hand branch will be formatted with global formatter
<details>
<summary><b>Global options</b></summary>
These are `options` that are used in options table.
They set behavior of lualine.
Values set here are treated as default for other options
that work in component level.
for example even though `icons_enabled` is a general component option.
you can set `icons_enabled` to `false` and icons will be disabled on all
component. You can still overwrite defaults set in option table by specifying
the option value in component.
```lua
options = {
icons_enabled = true, -- displays icons in alongside component
padding = 1, -- adds padding to the left and right of components
-- padding can be specified to left or right separately like
-- padding = { left = left_padding, right = right_padding }
fmt = nil -- fmt function, formats component's output
theme = 'auto', -- lualine theme
component_separators = {left = '', right = ''},
section_separators = {left = '', right = ''},
disabled_filetypes = {}, -- filetypes to diable lualine on
}
```
</details>
<details>
<summary><b>Local options</b></summary>
<summary><b>General component options</b></summary>
These are options that control behavior at component level
and are available for all components.
```lua
sections = {
lualine_a = {
{
'mode',
icons_enabled = true, -- displays icons in alongside component
icon = nil, -- displays icon in front of the component
separator = nil, -- Determines what separator to use for the component.
-- when a string is given it's treated as component_separator.
@ -375,6 +389,10 @@ sections = {
-- luae(lua expressions), vimf(viml function name)
-- luae is short for lua-expression and vimf is short fror vim-function
type = nil,
padding = 1, -- adds padding to the left and right of components
-- padding can be specified to left or right separately like
-- padding = { left = left_padding, right = right_padding }
fmt = nil, -- format function, formats component's output
}
}
}
@ -383,7 +401,11 @@ sections = {
</details>
<details>
<summary><b>Component specific local options</b></summary>
<summary><b>Component specific options</b></summary>
These are options that are available on specific components.
For example you have option on `diagnostics` component to
specify what your diagnostic sources will be.
#### buffers component options
@ -422,7 +444,7 @@ sections = {
-- 'nvim_lsp', 'nvim', 'coc', 'ale', 'vim_lsp'
-- Or a function that returns a table like
-- {error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt}
sources = {},
sources = {'nvim_lsp', 'coc'},
-- displays diagnostics from defined severity
sections = {'error', 'warn', 'info', 'hint'},
-- all colors are in format #rrggbb

View File

@ -82,7 +82,7 @@ Lualine has sections as shown below.
Each sections holds its components e.g. current vims mode.
Configuring from `.vim` file
Configuring lualine in init.vim
All the examples below are in lua. You can use the same examples in `.vim` file
by wrapping them in lua heredoc like this:
@ -313,24 +313,40 @@ shown. On the other hand branch will be formatted with global formatter
Global options ~
Available options These are `options` that are used in
options table. They set behavior of
lualine.
Values set here are treated as default for other options that work in component
level.
for example even though `icons_enabled` is a general component option. you can
set `icons_enabled` to `false` and icons will be disabled on all component. You
can still overwrite defaults set in option table by specifying the option value
in component.
>
options = {
icons_enabled = true, -- displays icons in alongside component
padding = 1, -- adds padding to the left and right of components
-- padding can be specified to left or right separately like
-- padding = { left = left_padding, right = right_padding }
fmt = nil -- fmt function, formats component's output
theme = 'auto', -- lualine theme
component_separators = {left = '', right = ''},
section_separators = {left = '', right = ''},
disabled_filetypes = {}, -- filetypes to diable lualine on
}
<
Local options ~
General component options ~
These are options that control behavior at component level and are available
for all components.
>
sections = {
lualine_a = {
{
'mode',
icons_enabled = true, -- displays icons in alongside component
icon = nil, -- displays icon in front of the component
separator = nil, -- Determines what separator to use for the component.
-- when a string is given it's treated as component_separator.
@ -354,13 +370,21 @@ Local options ~
-- luae(lua expressions), vimf(viml function name)
-- luae is short for lua-expression and vimf is short fror vim-function
type = nil,
padding = 1, -- adds padding to the left and right of components
-- padding can be specified to left or right separately like
-- padding = { left = left_padding, right = right_padding }
fmt = nil, -- format function, formats component's output
}
}
}
<
Component specific local options ~
Component specific options ~
These are options that are available on specific components. For example you
have option on `diagnostics` component to specify what your diagnostic sources
will be.
*lualine-buffers-component-options*
@ -400,7 +424,7 @@ Component specific local options ~
-- 'nvim_lsp', 'nvim', 'coc', 'ale', 'vim_lsp'
-- Or a function that returns a table like
-- {error=error_cnt, warn=warn_cnt, info=info_cnt, hint=hint_cnt}
sources = {},
sources = {'nvim_lsp', 'coc'},
-- displays diagnostics from defined severity
sections = {'error', 'warn', 'info', 'hint'},
-- all colors are in format #rrggbb

View File

@ -14,6 +14,10 @@ local default_options = {
fzf = 'FZF',
alpha = 'Alpha',
},
buffers_color = {
active = nil,
inactive = nil,
},
}
local function get_hl(section, is_active)
@ -42,13 +46,11 @@ end
function Buffer:get_props()
self.file = vim.fn.bufname(self.bufnr)
self.filepath = vim.fn.expand('#' .. self.bufnr .. ':p:~')
self.buftype = vim.api.nvim_buf_get_option(self.bufnr, 'buftype')
self.filetype = vim.api.nvim_buf_get_option(self.bufnr, 'filetype')
local modified = self.options.show_modified_status and vim.api.nvim_buf_get_option(self.bufnr, 'modified')
local modified_icon = self.options.icons_enabled and '' or ' +'
self.modified_icon = modified and modified_icon or ''
self.visible = vim.fn.bufwinid(self.bufnr) ~= -1
self.icon = ''
if self.options.icons_enabled then
local dev

View File

@ -49,7 +49,7 @@ local default_symbols = {
local default_options = {
colored = true,
update_in_insert = false,
sources = nil,
sources = { 'nvim_lsp', 'coc' },
sections = { 'error', 'warn', 'info', 'hint' },
diagnostics_color = {
error = {
@ -122,7 +122,7 @@ Diagnostics.new = function(self, options, child)
end
-- Error out no source
if new_diagnostics.options.sources == nil then
if #new_diagnostics.options.sources < 1 then
print 'no sources for diagnostics configured'
return ''
end

View File

@ -6,6 +6,10 @@ local highlight = require 'lualine.highlight'
local default_options = {
max_length = 0,
mode = 0,
tabs_color = {
active = nil,
inactive = nil,
},
}
local function get_hl(section, is_active)