/lsp_extensions.nvim

Repo to hold a bunch of info & extension callbacks for built-in LSP. Use at your own risk :wink:

Primary LanguageLuaMIT LicenseMIT

lsp_extensions.nvim

Repo to hold a bunch of info & extension callbacks for built-in LSP. Use at your own risk 😉

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: dart-outline-loclist

Rendering in fzf: dart-outline-fzf

Rendering in telescope: dart-outline-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