nvim-lua/lsp_extensions.nvim

github github
neovim-0.5
star 220
stars
alert-circle 12
open issues
users 15
subscribers
git-branch 21
forks
CREATED

2020-08-26

UPDATED

last month


lsp_extensions.nvim

I archived this repo because I think there are better language specific repos to handle the kinds of things we have here.

Feel free to copy anything inside of here and then use it in your own language-specific or feature-specific repos.

Thanks

  • TJ

Install

Requires Built-in LSP, Neovim Nightly, nvim-lsp

" LSP Extensions
Plug 'nvim-lua/lsp_extensions.nvim'

Available Features

Rust

Dart

Diagnostics

Inlay Hints (rust-analyzer)

Customized

Inlay hints for the whole file:

nnoremap <Leader>T :lua require'lsp_extensions'.inlay_hints()

Only current line:

nnoremap <Leader>t :lua require'lsp_extensions'.inlay_hints{ only_current_line = true }

Run on showing file or new file in buffer:

autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints{}

On cursor hover, get hints for current line:

autocmd CursorHold,CursorHoldI *.rs :lua require'lsp_extensions'.inlay_hints{ only_current_line = true }

By default only ChainingHint is enabled. This is due to Neovim not able to add virtual text injected into a line. To enable all hints: Note: Hints will overwrite if other hints using this. Only the last hint will be shown.

:lua require('lsp_extensions').inlay_hints{ enabled = {"TypeHint", "ChainingHint", "ParameterHint"} }

Available Options (Showing defaults):

require'lsp_extensions'.inlay_hints{
    highlight = "Comment",
    prefix = " > ",
    aligned = false,
    only_current_line = false,
    enabled = { "ChainingHint" }
}
autocmd InsertLeave,BufEnter,BufWinEnter,TabEnter,BufWritePost *.rs :lua require'lsp_extensions'.inlay_hints{ prefix = ' » ', highlight = "NonText", enabled = {"ChainingHint"} }

Closing Labels (dartls)

closing-labels

Closing Labels Documentation

Check out the example file for setup

Outline (dartls)

Rending in loclist:

Rendering in fzf:

Rendering in telescope:

Outline Documentation

Check out the example file for setup

Workspace Diagnostics

To enable workspace diagnostics, you'll want do something like this:

-- use the same configuration you would use for `vim.lsp.diagnostic.on_publish_diagnostics`.
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(
  require('lsp_extensions.workspace.diagnostic').handler, {
    signs = {
      severity_limit = "Error",
    }
  }
)

To use workspace diagnostics, you can do some of the following:

-- Get the counts from your curreent workspace:
local ws_errors = require('lsp_extensions.workspace.diagnostic').get_count(0, 'Error')
local ws_hints = require('lsp_extensions.workspace.diagnostic').get_count(0, 'Hint')

-- Set the qflist for the current workspace
--  For more information, see `:help vim.lsp.diagnostic.set_loc_list()`, since this has some of the same configuration.
require('lsp_extensions.workspace.diagnostic').set_qf_list()

Clips