diff --git a/lua/plugins/local/rooter/lua/rooter.lua b/lua/plugins/local/rooter/lua/rooter.lua deleted file mode 100644 index c09309a..0000000 --- a/lua/plugins/local/rooter/lua/rooter.lua +++ /dev/null @@ -1,99 +0,0 @@ -local plugin_name = 'rooter' -local log_level = vim.log.levels.WARN - -local function log(msg, level) - if level == vim.log.levels.ERROR then - vim.notify(plugin_name .. ':' .. msg, level) - else - print(msg) - end -end - -local function get_root() - local clients = vim.lsp.get_clients { bufnr = 0 } - if #clients == 0 then return vim.fs.root(0, { '.git' }) end - - -- Define priority order (higher priority first) - local priority_order = { - 'vtsls', - 'jsonls', - 'bashls', - 'yamlls', - } - - -- Find highest priority client - for _, priority_name in ipairs(priority_order) do - for _, client in ipairs(clients) do - if client.name == priority_name then return client.config.root_dir end - end - end - - -- Fallback to first client with a root_dir - for _, client in ipairs(clients) do - if client.config.root_dir then return client.config.root_dir end - end - - local git_root = vim.fs.root(0, { '.git' }) - if git_root then return git_root end - - log 'No LSP client found with root_dir' -end - -local function debounce(fn, ms) - local timer = nil - return function(...) - local args = { ... } - if timer then - timer:stop() - timer:close() - end - timer = vim.uv.new_timer() - timer:start(ms, 0, function() - vim.schedule(function() fn(unpack(args)) end) - timer:close() - timer = nil - end) - end -end - -local function on_lsp_attach() - local root = get_root() - if root then - log('root_dir detected: ' .. root, log_level) - vim.cmd('lcd ' .. root) - else - log('No project root found', log_level) - end -end - -local debounced_on_attacched = debounce(function() on_lsp_attach() end, 1000) - -local M = {} - --- Plugin configuration -M.config = { - greeting = 'Hello from rooter!', - some = 'option', -} - --- Main plugin function -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('tomru/rooter', { clear = true }), - callback = debounced_on_attacched, - }) -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 deleted file mode 100644 index 638450c..0000000 --- a/lua/plugins/local/rooter/plugin/rooter.lua +++ /dev/null @@ -1,3 +0,0 @@ -vim.api.nvim_create_user_command('Rooter', function() require('rooter').run() end, { - desc = 'Change working directory to the project root', -}) diff --git a/lua/plugins/project.lua b/lua/plugins/project.lua index 906c3e6..27cbae5 100644 --- a/lua/plugins/project.lua +++ b/lua/plugins/project.lua @@ -19,7 +19,7 @@ return { -- Table of lsp clients to ignore by name -- eg: { "efm", ... } - ignore_lsp = {}, + ignore_lsp = { 'copilot' }, -- Don't calculate root dir on specific directories -- Ex: { "~/.cargo/*", ... }