├── plugin └── lightline_lsp.vim ├── autoload └── lightline_lsp.vim ├── LICENSE └── README.md /plugin/lightline_lsp.vim: -------------------------------------------------------------------------------- 1 | if exists('g:loaded_lightline_lsp') 2 | finish 3 | endif 4 | let g:loaded_lightline_lsp = 1 5 | 6 | augroup lightline_lsp 7 | autocmd! 8 | autocmd User lsp_diagnostics_updated call lightline#update() 9 | augroup END 10 | -------------------------------------------------------------------------------- /autoload/lightline_lsp.vim: -------------------------------------------------------------------------------- 1 | function! lightline_lsp#warnings() abort 2 | let l:counts = lsp#get_buffer_diagnostics_counts() 3 | let l:sign = get(g:lsp_diagnostics_signs_warning, 'text', 'W') 4 | return l:counts.warning == 0 ? '' : printf('%s:%d', l:sign, l:counts.warning) 5 | endfunction 6 | 7 | function! lightline_lsp#errors() abort 8 | let l:counts = lsp#get_buffer_diagnostics_counts() 9 | let l:sign = get(g:lsp_diagnostics_signs_error, 'text', 'E') 10 | return l:counts.error == 0 ? '' : printf('%s:%d', l:sign, l:counts.error) 11 | endfunction 12 | 13 | function! lightline_lsp#ok() abort 14 | let l:counts = lsp#get_buffer_diagnostics_counts() 15 | let l:total = l:counts.error + l:counts.warning 16 | let l:sign = get(g:, 'lightline_lsp_signs_ok', 'OK') 17 | return l:total == 0 ? l:sign : '' 18 | endfunction 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Haruki Nakamura 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # lightline-lsp 2 | 3 | This plugin is a very simple plugin that integrates [lightline.vim](1) and [vim-lsp](2). 4 | Display the diagnostic result of vim-lsp in the statusline of lightline.vim. 5 | 6 | ## Install 7 | 8 | Install with your favorite plugin manager. 9 | Of course lightline.vim and vim-lsp are required. 10 | 11 | ## Usage 12 | 13 | For example, set `g:lightline` in vimrc. 14 | Just set `component_expand` to this plugin's autoload function and specify its type. 15 | See lightline.vim documentation for more infomation. 16 | 17 | ```vim 18 | let g:lightline = { 19 | \ 'active': { 20 | \ 'right': [ [ 'lsp_errors', 'lsp_warnings', 'lsp_ok', 'lineinfo' ], 21 | \ [ 'percent' ], 22 | \ [ 'fileformat', 'fileencoding', 'filetype' ] ] 23 | \ }, 24 | \ 'component_expand': { 25 | \ 'lsp_warnings': 'lightline_lsp#warnings', 26 | \ 'lsp_errors': 'lightline_lsp#errors', 27 | \ 'lsp_ok': 'lightline_lsp#ok', 28 | \ }, 29 | \ 'component_type': { 30 | \ 'lsp_warnings': 'warning', 31 | \ 'lsp_errors': 'error', 32 | \ 'lsp_ok': 'middle', 33 | \ }, 34 | \ } 35 | ``` 36 | 37 | ## Configuration 38 | 39 | The warning and error signs depend on the vim-lsp settings. 40 | See vim-lsp documentation for more infomation. 41 | The sign when vim-lsp diagnostic result does not exist is set with `g:lightline_lsp_signs_ok`. 42 | The default value if this global variable does not exist is `OK`. 43 | 44 | [1]: https://github.com/itchyny/lightline.vim "lightline.vim" 45 | [2]: https://github.com/prabirshrestha/vim-lsp "vim-lsp" 46 | --------------------------------------------------------------------------------