aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'nvim')
-rw-r--r--nvim/.config/nvim/lua/plugins/ferris.lua6
-rw-r--r--nvim/.config/nvim/lua/tobyvin/lsp/configs.lua34
2 files changed, 34 insertions, 6 deletions
diff --git a/nvim/.config/nvim/lua/plugins/ferris.lua b/nvim/.config/nvim/lua/plugins/ferris.lua
index 8a800c1..5010234 100644
--- a/nvim/.config/nvim/lua/plugins/ferris.lua
+++ b/nvim/.config/nvim/lua/plugins/ferris.lua
@@ -7,10 +7,4 @@ local M = {
},
}
-function M:init()
- U.lsp.on_attach("rust_analyzer", function()
- vim.keymap.set("n", "gx", require("ferris.methods.open_documentation"), { desc = "open external docs" })
- end, { desc = "setup ferris keymaps" })
-end
-
return M
diff --git a/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua b/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
index dc4c6f7..3aa0048 100644
--- a/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
+++ b/nvim/.config/nvim/lua/tobyvin/lsp/configs.lua
@@ -2,6 +2,7 @@
local ms = vim.lsp.protocol.Methods
+---@type table<string, lspconfig.Config>
local M = {
bashls = {
filetypes = { "sh", "PKGBUILD" },
@@ -140,6 +141,39 @@ local M = {
},
},
},
+ on_attach = function(client, bufnr)
+ vim.keymap.set({ "x", "n" }, "gx", function()
+ local params = vim.lsp.util.make_position_params(0, client.offset_encoding)
+ local resp, err = client.request_sync("experimental/externalDocs", params, nil, bufnr)
+
+ if resp == nil then
+ if err then
+ vim.notify(
+ string.format("External docs request failed: %s", err),
+ vim.log.levels.ERROR,
+ { title = client.name }
+ )
+ end
+ return "gx"
+ else
+ if resp.err then
+ vim.notify(
+ string.format(
+ "%s error: [%s] %s",
+ client.name,
+ resp.err.code or "unknown code",
+ resp.err.data or "(no description)"
+ ),
+ vim.log.levels.ERROR,
+ { title = client.name }
+ )
+ elseif resp.result then
+ vim.ui.open(resp.result["local"] or resp.result.web or resp.result)
+ end
+ return "<Ignore>"
+ end
+ end, { expr = true, desc = "open external docs", buffer = bufnr })
+ end,
},
ruff_lsp = {
on_attach = function(client)