feat(util): util.on_attach
This commit is contained in:
1 file changed
+12
@@ -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
|
||||
|
||||
Reference in new issue
Block a user