• This repository has been archived on 08/Jul/2022
  • Stars
    star
    213
  • Rank 179,402 (Top 4 %)
  • Language
    Lua
  • License
    MIT License
  • Created over 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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: 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