em, fix rooter structure a bit :doge:

This commit is contained in:
Thomas Ruoff
2025-06-04 08:37:21 +02:00
parent 0b6a27fff7
commit db4f67303a
3 changed files with 15 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
return { return {
dir = '~/.config/nvim/lua/plugins/local/rooter.lua', dir = '~/.config/nvim/lua/plugins/local/rooter',
name = 'rooter', name = 'rooter',
config = function() config = function()
require('rooter').setup { require('rooter').setup {

View File

@@ -1,4 +1,4 @@
local log_level = vim.log.levels.ERROR local log_level = vim.log.levels.WARN
local function log(msg, level) local function log(msg, level)
if level == vim.log.levels.ERROR then if level == vim.log.levels.ERROR then
@@ -81,13 +81,19 @@ function M.setup(opts)
M.config = vim.tbl_deep_extend('force', M.config, opts or {}) M.config = vim.tbl_deep_extend('force', M.config, opts or {})
vim.api.nvim_create_autocmd('LspAttach', { vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('my-rooter', { clear = true }), group = vim.api.nvim_create_augroup('tomru/rooter', { clear = true }),
callback = debounced_on_attacched, callback = debounced_on_attacched,
}) })
end
-- Create user commands function M.run()
-- vim.api.nvim_create_user_command('MyPluginGreet', function() print(M.config.greeting) end, {}) local root = get_root()
-- vim.api.nvim_create_user_command('MyPluginStatus', function() print('Plugin loaded with config:', vim.inspect(M.config)) end, {}) if root then
vim.cmd('lcd ' .. root)
log('Changed working directory to: ' .. root, log_level)
else
log('No project root found', log_level)
end
end end
return M return M

View File

@@ -0,0 +1,3 @@
vim.api.nvim_create_user_command('Rooter', function() require('rooter').run() end, {
desc = 'Change working directory to the project root',
})