made lazydev load only when in a lua file

This commit is contained in:
2026-04-16 09:59:52 +01:00
parent b76db809f2
commit ac461d7a6c
3 changed files with 42 additions and 3 deletions

View File

@@ -1,7 +1,6 @@
vim.pack.add({
{ src = "https://github.com/neovim/nvim-lspconfig", name = "lspconfig" },
{ src = "https://github.com/saghen/blink.cmp", name = "blink" },
{ src = "https://github.com/folke/lazydev.nvim", name = "lazydev" },
})
vim.lsp.config("lua_ls", {
@@ -81,9 +80,26 @@ require("blink.cmp").setup({
},
})
vim.api.nvim_create_autocmd("FileType", {
vim.api.nvim_create_autocmd("FileType", { -- Lazy load lazydev when in lua file (no pun intended)
pattern = "lua",
callback = function()
vim.pack.add({
{ src = "https://github.com/folke/lazydev.nvim", name = "lazydev" },
})
require("lazydev").setup()
require("blink.cmp").setup({ -- Reload blink with lazydev as a source
sources = {
-- add lazydev to your completion providers
default = { "lazydev", "lsp", "path", "snippets", "buffer" },
providers = {
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
},
},
},
})
end,
})