diff options
Diffstat (limited to 'lua/muwiki/config.lua')
| -rw-r--r-- | lua/muwiki/config.lua | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/lua/muwiki/config.lua b/lua/muwiki/config.lua index 1e04d4a..9d668b9 100644 --- a/lua/muwiki/config.lua +++ b/lua/muwiki/config.lua @@ -3,22 +3,8 @@ local M = {} M.options = { dirs = nil, index_file = 'index.md', - text_extensions = { 'md', 'txt' }, - use_external_handlers = false, - external_handlers = { - { - name = 'xdg-open', - cmd = 'xdg-open', - pattern = '.*', - }, - }, } -local function dir_exists(path) - local stat = vim.uv.fs_stat(path) - return stat and stat.type == 'directory' -end - function M.setup(opts) opts = opts or {} @@ -42,51 +28,11 @@ function M.setup(opts) end for _, dir in ipairs(M.options.dirs or {}) do - if not dir_exists(dir.path) then + local stat = vim.uv.fs_stat(dir.path) + if not (stat and stat.type == 'directory') then vim.notify('Wiki directory not found: ' .. dir.path, vim.log.levels.WARN) end end end --- Lookup wiki path by name (e.g., "default" -> "~/wiki/") -function M.wiki_path(name) - if not M.options.dirs or #M.options.dirs == 0 then - vim.notify('MuWiki: No dirs configured. See :help muwiki-configuration', vim.log.levels.ERROR) - return nil - end - - if name then - for _, dir in ipairs(M.options.dirs) do - if dir.name == name then - return dir.path - end - end - vim.notify(string.format('Wiki "%s" not found, using default', name), vim.log.levels.WARN) - end - - return M.options.dirs[1].path -end - --- Find which wiki contains this buffer's file (cached per-buffer) -function M.wiki_root(bufnr) - bufnr = bufnr or 0 - - if vim.b[bufnr].muwiki_root ~= nil then - return vim.b[bufnr].muwiki_root or nil - end - - local filepath = vim.api.nvim_buf_get_name(bufnr) - local normalized = vim.fs.normalize(filepath) - - for _, dir in ipairs(M.options.dirs or {}) do - if vim.startswith(normalized, dir.path) then - vim.b[bufnr].muwiki_root = dir.path - return dir.path - end - end - - vim.b[bufnr].muwiki_root = false - return nil -end - return M |
