1
- local methods = require (" null-ls.methods" )
2
- local u = require (" null-ls.utils" )
3
1
local c = require (" null-ls.config" )
4
2
local log = require (" null-ls.logger" )
3
+ local methods = require (" null-ls.methods" )
5
4
6
5
local lsp = vim .lsp
7
6
local api = vim .api
8
7
8
+ -- adapted from nvim-lspconfig's :LspInfo window
9
+ local make_window = function (height_percentage , width_percentage )
10
+ local row_start_percentage = (1 - height_percentage ) / 2
11
+ local col_start_percentage = (1 - width_percentage ) / 2
12
+
13
+ local row = math.ceil (vim .o .lines * row_start_percentage )
14
+ local col = math.ceil (vim .o .columns * col_start_percentage )
15
+ local width = math.floor (vim .o .columns * width_percentage )
16
+ local height = math.ceil (vim .o .lines * height_percentage )
17
+
18
+ local opts = {
19
+ relative = " editor" ,
20
+ row = row ,
21
+ col = col ,
22
+ width = width ,
23
+ height = height ,
24
+ style = " minimal" ,
25
+ border = {
26
+ { " " , " NormalFloat" },
27
+ { " " , " NormalFloat" },
28
+ { " " , " NormalFloat" },
29
+ { " " , " NormalFloat" },
30
+ { " " , " NormalFloat" },
31
+ { " " , " NormalFloat" },
32
+ { " " , " NormalFloat" },
33
+ { " " , " NormalFloat" },
34
+ },
35
+ }
36
+
37
+ local bufnr = api .nvim_create_buf (false , true )
38
+ local win_id = api .nvim_open_win (bufnr , true , opts )
39
+ api .nvim_win_set_buf (win_id , bufnr )
40
+
41
+ vim .cmd (" setlocal nocursorcolumn ts=2 sw=2" )
42
+
43
+ return {
44
+ bufnr = bufnr ,
45
+ win_id = win_id ,
46
+ }
47
+ end
48
+
9
49
local M = {}
10
50
11
51
M .get_active_sources = function (bufnr , ft )
@@ -23,9 +63,7 @@ M.get_active_sources = function(bufnr, ft)
23
63
end
24
64
25
65
M .show_window = function ()
26
- local windows = require (" lspconfig.ui.windows" )
27
-
28
- local client = u .get_client ()
66
+ local client = require (" null-ls.client" ).get_client ()
29
67
local bufnr = api .nvim_get_current_buf ()
30
68
if not client or not lsp .buf_is_attached (bufnr , client .id ) then
31
69
log :warn (" failed to get info: buffer is not attached" )
@@ -52,7 +90,7 @@ M.show_window = function()
52
90
table.insert (lines , methods .readable [method ] .. " : " .. table.concat (sources , " , " ))
53
91
end
54
92
55
- local win_info = windows . percentage_range_window (0.8 , 0.7 )
93
+ local win_info = make_window (0.8 , 0.7 )
56
94
local win_bufnr , win_id = win_info .bufnr , win_info .win_id
57
95
58
96
api .nvim_buf_set_lines (win_bufnr , 0 , - 1 , true , lines )
0 commit comments