kawre / leetcode.nvim

A Neovim plugin enabling you to solve LeetCode problems.
MIT License
655 stars 34 forks source link

'win' cannot be passed for buffer-local option 'filetype' #13

Closed kawre closed 8 months ago

kawre commented 8 months ago
          Not sure what changed, but after nvim update and LazyVim and lazyvim.nvim update, now even `nvim leetcode.nvim` doesn't work. 
 {
    "kawre/leetcode.nvim",
    build = ":TSUpdate html",
    dependencies = {
      "MunifTanjim/nui.nvim",
      "nvim-lua/plenary.nvim", -- required by telescope
      "nvim-telescope/telescope.nvim",
      "nvim-tree/nvim-web-devicons",
      "nvim-treesitter/nvim-treesitter",
      "rcarriga/nvim-notify",
    },
    opts = {
      lang = "rust",
      -- sql = "postgresql"
    },
    config = function(_, opts)
      vim.keymap.set("n", "<leader>lq", "<cmd>LcQuestionTabs<cr>")
      vim.keymap.set("n", "<leader>lm", "<cmd>LcMenu<cr>")
      vim.keymap.set("n", "<leader>lc", "<cmd>LcConsole<cr>")
      vim.keymap.set("n", "<leader>ll", "<cmd>LcLanguage<cr>")
      vim.keymap.set("n", "<leader>ld", "<cmd>LcDescriptionToggle<cr>")

      require("leetcode").setup(opts)
    end,
  },

is my setup.

After adding event = "BufEnter" for leetcode.nvim in my setup above, I see this:

Error executing lua callback: ...hare/nvim/lazy/leetcode.nvim/lua/leetcode-menu/utils.lua:10: 'win' cannot be passed for buffer-local option 'filetype'
stack traceback:
    [C]: in function 'nvim_set_option_value'
    ...hare/nvim/lazy/leetcode.nvim/lua/leetcode-menu/utils.lua:10: in function 'apply_opt_local'
    ...share/nvim/lazy/leetcode.nvim/lua/leetcode-menu/init.lua:120: in function 'init'
    ...tu/.local/share/nvim/lazy/leetcode.nvim/lua/leetcode.lua:61: in function 'start'
    ...tu/.local/share/nvim/lazy/leetcode.nvim/lua/leetcode.lua:72: in function <...tu/.local/share/nvim/lazy/leetcode.nvim/lua/leetcode.lua:72>

Originally posted by @surmish in https://github.com/kawre/leetcode.nvim/issues/10#issuecomment-1763096071

kawre commented 8 months ago

Can you check if anything changed on 3a8886c?

kawre commented 8 months ago

and what is your exact version of neovim

surmish commented 8 months ago

The fix worked for this issue. Thanks. I compiled nvim myself after git pull --ff-only just an hour ago:

NVIM v0.10.0-dev-1351+g28ef4a449
Build type: Release
LuaJIT 2.1.0-beta3
# compile command used
sudo make CMAKE_BUILD_TYPE=Release CMAKE_INSTALL_PREFIX=/usr/local USE_BUNDLED=OFF LIBLUV_LIBRARY=/usr/local/lib/lua/5.1/libluv.so LIBLUV_INCLUDE_DIR=/usr/local/include/luv install
kawre commented 8 months ago

@surmish it should be fully functional right now as the 3a8886c didn't include buffer options.

surmish commented 8 months ago

@surmish it should be fully functional right now as the 3a8886c didn't include buffer options.

Thanks.

One suggestion, in the buffer with the problem statement, you can set the filetype to markdown. It renders quite well with LazyVim markdown extra:

image

(In the left buffer, I ran :set ft=markdown and which invokes this: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/plugins/extras/lang/markdown.lua)

kawre commented 8 months ago

Can you post a screenshot of the description without :set ft=markdown?

surmish commented 8 months ago

image