项目作者: spywhere

项目描述 :
LSP diagnostic indicator for the lightline vim plugin
高级语言: Vim script
项目地址: git://github.com/spywhere/lightline-lsp.git
创建时间: 2021-01-16T19:30:05Z
项目社区:https://github.com/spywhere/lightline-lsp

开源协议:Other

下载


lightline-lsp

This plugin provides neovim’s LSP diagnostic indicator for the lightline vim plugin.

screenshot

Table Of Contents

Installation

Install using a plugin manager of your choice, for example:

  1. " neovim 0.5 or later which support lsp and lua
  2. Plug 'itchyny/lightline.vim' " Dependency: status line
  3. Plug 'spywhere/lightline-lsp'

Integration

  1. Register the components:
  1. let g:lightline = {}
  2. let g:lightline.component_expand = {
  3. \ 'linter_hints': 'lightline#lsp#hints',
  4. \ 'linter_infos': 'lightline#lsp#infos',
  5. \ 'linter_warnings': 'lightline#lsp#warnings',
  6. \ 'linter_errors': 'lightline#lsp#errors',
  7. \ 'linter_ok': 'lightline#lsp#ok',
  8. \ }
  1. Set color to the components:
  1. let g:lightline.component_type = {
  2. \ 'linter_hints': 'right',
  3. \ 'linter_infos': 'right',
  4. \ 'linter_warnings': 'warning',
  5. \ 'linter_errors': 'error',
  6. \ 'linter_ok': 'right',
  7. \ }
  1. Add the components to the lightline, for example to the right side:
  1. let g:lightline.active = { 'right': [[ 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_hints', 'linter_ok' ]] }

Configuration

g:lightline#lsp#indicator_hints

The indicator to use when there are hints. Default is H:.

g:lightline#lsp#indicator_infos

The indicator to use when there are infos. Default is I:.

g:lightline#lsp#indicator_warnings

The indicator to use when there are warnings. Default is W:.

g:lightline#lsp#indicator_errors

The indicator to use when there are errors. Default is E:.

g:lightline#lsp#indicator_ok

The indicator to use when there are no diagnostic. Default is OK.

g:lightline#lsp#update_in_insert

Update diagnostic in insert mode. Default is v:true.

Using icons as indicators

If you would like to replace the default indicators with symbols like on the screenshot, then you’ll need to ensure you have some “iconic fonts” installed, such as Font Awesome. A common alternative is to replace your primary font with one of the Patched Nerd Fonts, which saves you from having to install multiple fonts.

The following icons from the Font Awesome font are used in the screenshot:

To specify icons in the configuration, use their unicode codes as "\uXXXX" (make sure to wrap them in double quotes). Alternatively copy the icons from a font website, or type \u\<4-digit-unicode\> or \U\<8-digit-unicode\> to insert the literal characters.

See the code points here:

Here’s the configuration snippet used in the screenshot:

  1. let g:lightline#lsp#indicator_hints = "\uf002"
  2. let g:lightline#lsp#indicator_infos = "\uf129"
  3. let g:lightline#lsp#indicator_warnings = "\uf071"
  4. let g:lightline#lsp#indicator_errors = "\uf05e"
  5. let g:lightline#lsp#indicator_ok = "\uf00c"

Contributes

During the development, you can use the following command to automatically setup
a working configurations to test the plugin against TSServer LSP…

  1. make testrun

or

  1. nvim -u tests/init.lua tests/sample.js

License

Released under the ISC License
based on the work by Maxim Baz on lightline-ale