feat(util): util.on_attach

This commit is contained in:
Folke Lemaitre committed 2023-01-02 17:35:59 +01:00
1 parent 7750887703
commit e6dfed58f7
1 file changed
+12
+12
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