Enable opt in project configs
This commit is contained in:
4
init.lua
4
init.lua
@@ -12,6 +12,10 @@ end
|
|||||||
-- load config from lua/local.lua if present
|
-- load config from lua/local.lua if present
|
||||||
pcall(function() require('local') end)
|
pcall(function() require('local') end)
|
||||||
|
|
||||||
|
-- source project-local .nvim.lua from cwd upwards, if trusted (see :h 'exrc')
|
||||||
|
-- must be set here: plugin/ scripts load after exrc is processed
|
||||||
|
vim.o.exrc = true
|
||||||
|
|
||||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||||
if not vim.uv.fs_stat(lazypath) then
|
if not vim.uv.fs_stat(lazypath) then
|
||||||
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
vim.fn.system({ 'git', 'clone', '--filter=blob:none',
|
||||||
|
|||||||
@@ -206,6 +206,34 @@ vim.api.nvim_create_user_command('DiagnosticToggle', function(_)
|
|||||||
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
vim.diagnostic.enable(not vim.diagnostic.is_enabled())
|
||||||
end, {})
|
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
|
-- :ResizeFixed acts like :resize but also fixes the window size so it stops
|
||||||
-- automatically changing when other windows reflow. Respects the :vertical
|
-- automatically changing when other windows reflow. Respects the :vertical
|
||||||
-- modifier, resizing and fixing the width instead of the height.
|
-- modifier, resizing and fixing the width instead of the height.
|
||||||
|
|||||||
Reference in New Issue
Block a user