diff --git a/lua/plugins/local.lua b/lua/plugins/local.lua index 585749a..f4ff811 100644 --- a/lua/plugins/local.lua +++ b/lua/plugins/local.lua @@ -1,5 +1,5 @@ return { - dir = '~/.config/nvim/lua/plugins/local/rooter.lua', + dir = '~/.config/nvim/lua/plugins/local/rooter', name = 'rooter', config = function() require('rooter').setup { diff --git a/lua/plugins/local/rooter.lua b/lua/plugins/local/rooter/lua/rooter.lua similarity index 83% rename from lua/plugins/local/rooter.lua rename to lua/plugins/local/rooter/lua/rooter.lua index 6b20b16..d1b8a93 100644 --- a/lua/plugins/local/rooter.lua +++ b/lua/plugins/local/rooter/lua/rooter.lua @@ -1,4 +1,4 @@ -local log_level = vim.log.levels.ERROR +local log_level = vim.log.levels.WARN local function log(msg, level) 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 {}) 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, }) +end - -- Create user commands - -- vim.api.nvim_create_user_command('MyPluginGreet', function() print(M.config.greeting) end, {}) - -- vim.api.nvim_create_user_command('MyPluginStatus', function() print('Plugin loaded with config:', vim.inspect(M.config)) end, {}) +function M.run() + local root = get_root() + 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 return M diff --git a/lua/plugins/local/rooter/plugin/rooter.lua b/lua/plugins/local/rooter/plugin/rooter.lua new file mode 100644 index 0000000..638450c --- /dev/null +++ b/lua/plugins/local/rooter/plugin/rooter.lua @@ -0,0 +1,3 @@ +vim.api.nvim_create_user_command('Rooter', function() require('rooter').run() end, { + desc = 'Change working directory to the project root', +})