mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 17:28:57 +02:00
feat(util): util.on_attach
This commit is contained in:
parent
7750887703
commit
e6dfed58f7
1 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue