Skip to content

Commit 9cf263a

Browse files
committed
remove nvim 9 support
1 parent 94d7291 commit 9cf263a

File tree

2 files changed

+5
-49
lines changed

2 files changed

+5
-49
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# LSPLINKS
22

3-
> Support for [document links](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentLink) for neovim **0.9+**.
3+
> Support for [document links](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_documentLink) for neovim **0.10+**.
44
55
### Usage
66

lua/lsplinks.lua

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,6 @@ local function in_range(pos, range)
5656
end
5757
end
5858

59-
---@param name string
60-
---@return boolean
61-
local function lsp_has_capability(name)
62-
local clients = nil
63-
if vim.lsp.get_clients then
64-
local bufnr = api.nvim_get_current_buf()
65-
clients = vim.lsp.get_clients({ bufnr = bufnr })
66-
else
67-
clients = vim.lsp.buf_get_clients()
68-
end
69-
for _, client in ipairs(clients) do
70-
if client.server_capabilities[name] then
71-
return true
72-
end
73-
end
74-
return false
75-
end
7659

7760
local augroup = api.nvim_create_augroup("lsplinks", { clear = true })
7861

@@ -108,18 +91,6 @@ function M.current()
10891
return nil
10992
end
11093

111-
--- Return the uri without the fragment
112-
---
113-
---@param uri string
114-
---@return string
115-
local function remove_uri_fragment(uri)
116-
local fragment_index = uri:find("#")
117-
if fragment_index ~= nil then
118-
uri = uri:sub(1, fragment_index - 1)
119-
end
120-
return uri
121-
end
122-
12394
--- Open the link under the cursor if one exists.
12495
--- The return value indicates if a link was found.
12596
---
@@ -131,26 +102,13 @@ function M.open(uri)
131102
return false
132103
end
133104
if uri:find("^file:/") then
134-
util.show_document({ uri = remove_uri_fragment(uri) }, "utf-8", { reuse_win = true, focus = true })
105+
util.show_document({ uri = uri }, "utf-8", { reuse_win = true, focus = true })
135106
local line_no, col_no = uri:match(".-#(%d+),(%d+)")
136107
if line_no then
137108
api.nvim_win_set_cursor(0, { tonumber(line_no), tonumber(col_no) - 1 })
138109
end
139110
else
140-
if vim.ui.open then
141-
vim.ui.open(uri)
142-
else
143-
-- for nvim earlier than 0.10
144-
local opener
145-
if vim.fn.has("macunix") == 1 then
146-
opener = "open"
147-
elseif vim.fn.has("linux") == 1 then
148-
opener = "xdg-open"
149-
elseif vim.fn.has("win64") == 1 or vim.fn.has("win32") == 1 then
150-
opener = "start"
151-
end
152-
vim.fn.system(string.format("%s '%s' >/dev/null 2>&1", opener, uri))
153-
end
111+
vim.ui.open(uri)
154112
end
155113
return true
156114
end
@@ -164,9 +122,6 @@ end
164122

165123
-- Refresh the links for the current buffer
166124
function M.refresh()
167-
if not lsp_has_capability("documentLinkProvider") then
168-
return
169-
end
170125
local params = { textDocument = util.make_text_document_params() }
171126
vim.lsp.buf_request(0, "textDocument/documentLink", params, function(err, result, ctx)
172127
if err then
@@ -190,7 +145,8 @@ function M.refresh()
190145
if options.highlight then
191146
M.display()
192147
end
193-
end)
148+
end, function() end
149+
)
194150
end
195151

196152
--- Get links for bufnr

0 commit comments

Comments
 (0)