Enable opt in project configs
This commit is contained in:
@@ -206,6 +206,34 @@ vim.api.nvim_create_user_command('DiagnosticToggle', function(_)
|
||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||
end, {})
|
||||
|
||||
-- :Exrc create a project-local .nvim.lua in the current directory which adds a
|
||||
-- local runtime directory to 'runtimepath', defaulting to .config/nvim. Bang to
|
||||
-- overwrite an existing file. The result is trusted so it is sourced on the next
|
||||
-- start, editing it revokes that and requires :trust again. See :h 'exrc'.
|
||||
vim.api.nvim_create_user_command('Exrc', function(opts)
|
||||
local path = vim.fs.joinpath(vim.fn.getcwd(), '.nvim.lua')
|
||||
if vim.uv.fs_stat(path) and not opts.bang then
|
||||
vim.notify(path .. ' already exists, use :Exrc! to overwrite',
|
||||
vim.log.levels.ERROR)
|
||||
return
|
||||
end
|
||||
local dir = opts.args ~= '' and opts.args or '.config/nvim'
|
||||
vim.fn.writefile({
|
||||
"local root = vim.fs.dirname(debug.getinfo(1, 'S').source:gsub('^@', ''))",
|
||||
"local dir = vim.fs.joinpath(root, '" .. dir .. "')",
|
||||
'',
|
||||
'vim.opt.runtimepath:prepend(dir)',
|
||||
"vim.opt.runtimepath:append(vim.fs.joinpath(dir, 'after'))",
|
||||
'',
|
||||
"-- lazy.nvim unsets 'loadplugins' so source this dir's plugin/ files here",
|
||||
"for _, file in ipairs(vim.fn.glob(dir .. '/plugin/**/*.lua', false, true)) do",
|
||||
' dofile(file)',
|
||||
'end',
|
||||
}, path)
|
||||
vim.secure.trust({ action = 'allow', path = path })
|
||||
vim.cmd.edit(path)
|
||||
end, { bang = true, nargs = '?', complete = 'dir' })
|
||||
|
||||
-- :ResizeFixed acts like :resize but also fixes the window size so it stops
|
||||
-- automatically changing when other windows reflow. Respects the :vertical
|
||||
-- modifier, resizing and fixing the width instead of the height.
|
||||
|
||||
Reference in New Issue
Block a user