mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
32 lines
1.1 KiB
Lua
32 lines
1.1 KiB
Lua
local M = {}
|
|
|
|
M.on_attach = function(client, bufnr)
|
|
local telescope = require("telescope.builtin")
|
|
local methods = vim.lsp.protocol.Methods
|
|
local function nnoremap(bind, callback, userargs)
|
|
local args = userargs or {}
|
|
args.buffer = bufnr
|
|
vim.keymap.set("n", bind, callback, args)
|
|
end
|
|
|
|
nnoremap("K", vim.lsp.buf.hover)
|
|
nnoremap("<C-k>", vim.lsp.buf.signature_help)
|
|
nnoremap("gd", telescope.lsp_definitions)
|
|
nnoremap("gu", telescope.lsp_references)
|
|
nnoremap("<leader>ca", vim.lsp.buf.code_action)
|
|
nnoremap("<leader>cl", vim.lsp.codelens.run)
|
|
nnoremap("<leader>r", vim.lsp.buf.rename)
|
|
nnoremap("<leader>f", function() vim.lsp.buf.format { async = true } end)
|
|
|
|
local filetype = vim.api.nvim_get_option_value("filetype", { buf = bufnr })
|
|
if
|
|
client:supports_method(methods.textDocument_inlayHint)
|
|
-- Never start cabal with inlay hint request
|
|
-- Related: https://github.com/mrcjkb/haskell-tools.nvim/discussions/485
|
|
and filetype ~= "cabal"
|
|
then
|
|
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
|
end
|
|
end
|
|
|
|
return M
|