Skip to content

Conversation

jayeheffernan
Copy link

This PR adds a way to control the format of the question filenames, by passing a function in your config. Here's a sample config that uses it:

return {
  "kawre/leetcode.nvim",
  build = ":TSUpdate html", -- if you have `nvim-treesitter` installed
  dependencies = {
    -- "nvim-telescope/telescope.nvim",
    "ibhagwan/fzf-lua",
    "nvim-lua/plenary.nvim",
    "MunifTanjim/nui.nvim",
  },
  opts = {
    lang = "rust",
    storage = {
      home = vim.fn.stdpath("data") .. "/leetcode/src/bin",
      cache = vim.fn.stdpath("cache") .. "/leetcode",
      format = function(opts)
        local fn = ("%s__%s%s.%s"):format(opts.id, opts.slug, opts.ft_alt, opts.ft)
        return fn
      end,
    },
  },
}

Motivation

I wanted to use src/bin in a Rust project as a home folder, so that LSP stuff and commands like cargo fmt and cargo test work smoothly. But I ran into this problem (e.g. running cargo test):

error: invalid character `'.'` in crate name: `9.palindrome-number`

So I want the filenames not to include ".".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant