Skip to content
This repository was archived by the owner on Jul 7, 2022. It is now read-only.

Commit 5b87f8f

Browse files
authored
Merge pull request #1 from rockerBOO/setup
LSP Extensions using inlay_hints entry function
2 parents c441df2 + 6b8d529 commit 5b87f8f

File tree

3 files changed

+53
-11
lines changed

3 files changed

+53
-11
lines changed

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,60 @@
22

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

5+
## Install
6+
7+
Requires Built-in LSP, [Neovim Nightly](https://github.com/neovim/neovim/releases/tag/nightly), [nvim-lsp](https://github.com/neovim/nvim-lsp)
8+
9+
```vimscript
10+
" LSP Extensions (inlay-hints)
11+
Plug "tjdevries/lsp_extensions.nvim"
12+
```
13+
14+
## Inlay Hints (rust-analyzer)
15+
16+
![inlay-hints](https://i.imgur.com/YsOfqOk.png)
17+
18+
Inlay hints for the whole file:
19+
20+
```vimscript
21+
nnoremap <Leader>T :lua require'lsp_extensions'.inlay_hints()
22+
```
23+
24+
Only current line:
25+
26+
```vimscript
27+
nnoremap <Leader>t :lua require'lsp_extensions'.inlay_hints{ only_current_line = true }
28+
```
29+
30+
Run on showing file or new file in buffer:
31+
32+
```vimscript
33+
autocmd BufEnter,BufWinEnter,TabEnter *.rs :lua require'lsp_extensions'.inlay_hints{}
34+
```
35+
36+
On cursor hover, get hints for current line:
37+
38+
```vimscript
39+
autocmd CursorHold,CursorHoldI *.rs :lua require'lsp_extensions'.inlay_hints{ only_current_line = true }
40+
```
41+
42+
Available Options (Showing defaults):
43+
44+
```lua
45+
require'lsp_extensions'.inlay_hints{
46+
highlight = "Comment",
47+
prefix = " > ",
48+
aligned = false,
49+
only_current_line = false
50+
}
51+
```
552

653
## Clips
754

855
- Showing Line Diagnostics: https://clips.twitch.tv/ProductiveBoxyPastaCoolStoryBro
956

1057
- This Plugin:
11-
- Lined up hints: https://clips.twitch.tv/DaintyCorrectMarjoramKeepo
58+
59+
- Lined up hints: https://clips.twitch.tv/DaintyCorrectMarjoramKeepo
1260

1361
- N E O V I M: https://clips.twitch.tv/SmoothGoodTurnipCmonBruh

lua/lsp_extensions/init.lua

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,12 @@ Each extension should probably look like:
1616
1717
--]]
1818

19+
local vim = vim
1920
local extensions = {}
21+
local inlay_hints = require('lsp_extensions.inlay_hints')
2022

21-
22-
extensions.test = function(highlight)
23-
highlight = highlight or "Comment"
24-
25-
local inlay_hints = require('lsp_extensions.inlay_hints')
26-
vim.lsp.buf_request(0, 'rust-analyzer/inlayHints', inlay_hints.get_params(), inlay_hints.get_callback {
27-
only_current_line = false,
28-
aligned = true
29-
})
23+
extensions.inlay_hints = function(opts)
24+
vim.lsp.buf_request(0, 'rust-analyzer/inlayHints', inlay_hints.get_params(), inlay_hints.get_callback(opts))
3025
end
3126

3227
return extensions

plugin/lsp_extensions.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
21
nnoremap ,asdf :lua require('plenary.reload').reload_module('lsp_extensions'); require('lsp_extensions').test()<CR>

0 commit comments

Comments
 (0)