Skip to content

Commit 148637f

Browse files
committed
make nvim-notify optional
1 parent 6945895 commit 148637f

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,34 @@ I wanted to create a solution that would provide better visibility into the LSP'
1212
![image](https://user-images.githubusercontent.com/347098/212483720-e6c7b782-1aa1-49ad-b45a-8502b2b9cbf5.png)
1313
![image](https://user-images.githubusercontent.com/347098/212483653-e1fb1f5a-5826-400a-b79e-cba754e4fe2e.png)
1414

15-
### Required dependencies
15+
### Optional dependencies
1616

1717
- [nvim-notify](https://github.com/rcarriga/nvim-notify)
1818

1919
### Installation
2020

2121
Using [packer.nvim](https://github.com/wbthomason/packer.nvim)
2222

23+
Basinc setup will use `vim.notify()` for notifications:
2324
```lua
2425
use {
2526
'mrded/nvim-lsp-notify',
26-
requires = { 'rcarriga/nvim-notify' },
27-
config = function()
28-
require('lsp-notify').setup({})
29-
end
27+
config = function()
28+
require('lsp-notify').setup({})
29+
end
30+
}
31+
```
32+
33+
You can also pass `notify` function, for example from [nvim-notify](https://github.com/rcarriga/nvim-notify):
34+
```lua
35+
use {
36+
'mrded/nvim-lsp-notify',
37+
requires = { 'rcarriga/nvim-notify' },
38+
config = function()
39+
require('lsp-notify').setup({
40+
notify = require('notify'),
41+
})
42+
end
3043
}
3144
```
3245

doc/zond.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,10 @@ lsp-notify is a plugin designed to keep you informed of the progress of your LSP
66

77
setup({opts}) *lsp-notify.setup()*
88
Configure nvim-lsp-notify
9+
10+
Parameters: ~
11+
{opts} (table) options to pass to the function
12+
13+
Options: ~
14+
{notify} (function) function to show the notification
15+
(default: 'vim.notify')

lua/lsp-notify/init.lua

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
local notify = require('notify')
1+
local notify = vim.notify
2+
23
local client_notifs = {}
34

45
local function get_notif_data(client_id, token)
@@ -64,7 +65,11 @@ vim.lsp.handlers["window/showMessage"] = function(err, method, params, client_id
6465
end
6566

6667
return {
67-
setup = function()
68-
-- TODO: add config options
68+
setup = function(opts)
69+
opts = opts or {}
70+
71+
if opts.notify then
72+
notify = opts.notify
73+
end
6974
end
7075
}

0 commit comments

Comments
 (0)