feat(util): util.on_attach

This commit is contained in:
Folke Lemaitre 2023-01-02 17:35:59 +01:00
parent 7750887703
commit e6dfed58f7
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -1,6 +1,18 @@
local M = {}
M.root_patterns = { ".git", "/lua" }
---@param on_attach fun(client, buffer)
function M.on_attach(on_attach)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local buffer = args.buf
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end
-- returns the root directory based on:
-- * lsp workspace folders
-- * lsp root_dir