mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
nvim: move out lsp on_attach
This commit is contained in:
parent
3352b3b6e6
commit
65f5e1107b
2 changed files with 40 additions and 32 deletions
32
.config/nvim/lua/lsp.lua
Normal file
32
.config/nvim/lua/lsp.lua
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue