feat: use mini.safely for file events
This commit is contained in:
@@ -13,10 +13,9 @@ local gr = vim.api.nvim_create_augroup("custom-config", {})
|
||||
_G.Config = {
|
||||
now = function(f) misc.safely("now", f) end,
|
||||
later = function(f) misc.safely("later", f) end,
|
||||
autocmd = function(event, pattern, callback, desc, once)
|
||||
vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc, once = once })
|
||||
end
|
||||
on_event = function(ev, f) misc.safely('event:' .. ev, f) end,
|
||||
on_filetype = function(ft, f) misc.safely('filetype:' .. ft, f) end,
|
||||
autocmd = function(event, pattern, callback, desc) vim.api.nvim_create_autocmd(event, { group = gr, pattern = pattern, callback = callback, desc = desc }) end
|
||||
}
|
||||
|
||||
Config.now_if_args = vim.fn.argc(-1) > 0 and Config.now or Config.later
|
||||
|
||||
|
||||
+3
-3
@@ -77,9 +77,9 @@ Config.now_if_args(function()
|
||||
},
|
||||
})
|
||||
|
||||
Config.autocmd('LspAttach', nil, function(ev)
|
||||
vim.bo[ev.buf].omnifunc = 'v:lua.MiniCompletion.completefunc_lsp'
|
||||
end, "Set 'omnifunc'")
|
||||
Config.on_event('LspAttach', function()
|
||||
vim.bo.omnifunc = 'v:lua.MiniCompletion.completefunc_lsp'
|
||||
end)
|
||||
|
||||
vim.lsp.config('*', { capabilities = MiniCompletion.get_lsp_capabilities() })
|
||||
end)
|
||||
|
||||
+11
-9
@@ -17,11 +17,12 @@ Config.now_if_args(function()
|
||||
'json', 'xml', 'toml', 'sh', 'bash', 'zsh', 'just', 'gitcommit', 'diff', 'regex', 'http'
|
||||
}
|
||||
|
||||
Config.autocmd('FileType', filetypes, function(ev)
|
||||
if pcall(vim.treesitter.start, ev.buf) and vim.bo[ev.buf].filetype == 'php' then
|
||||
vim.bo[ev.buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
Config.on_filetype(table.concat(filetypes, ','), function()
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if pcall(vim.treesitter.start, buf) and vim.bo[buf].filetype == 'php' then
|
||||
vim.bo[buf].indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
|
||||
end
|
||||
end, 'Start tree-sitter')
|
||||
end)
|
||||
|
||||
Config.later(function()
|
||||
require('nvim-treesitter').install(vim.tbl_map(function(ft)
|
||||
@@ -73,16 +74,17 @@ Config.later(function()
|
||||
require("dap").adapters.go = { type = "server", host = "127.0.0.1", port = "${port}" }
|
||||
end)
|
||||
|
||||
-- Kulala & Flutter
|
||||
Config.autocmd('FileType', { 'http' }, function()
|
||||
-- Kulala
|
||||
Config.on_filetype('http', function()
|
||||
vim.pack.add({ "https://github.com/mistweaverco/kulala.nvim" })
|
||||
require("kulala").setup({ default_env = "dev" })
|
||||
end, "Setup Kulala", true)
|
||||
end)
|
||||
|
||||
Config.autocmd('FileType', 'dart', function()
|
||||
-- Flutter
|
||||
Config.on_filetype('dart', function()
|
||||
vim.pack.add({
|
||||
"https://github.com/nvim-lua/plenary.nvim",
|
||||
"https://github.com/nvim-flutter/flutter-tools.nvim",
|
||||
})
|
||||
require("flutter-tools").setup({ lsp = { color_capabilities = true } })
|
||||
end, "Setup Flutter", true)
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user