Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

looking-glass module does not allow LSPs and other language-specific tools to kick in as it states in the wiki #1123

Open
2 tasks done
taujiong opened this issue Oct 21, 2023 · 1 comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.

Comments

@taujiong
Copy link

Prerequisites

  • I am using the latest stable release of Neovim
  • I am using the latest version of the plugin

Neovim Version

0.9.4

Neorg setup

Actually there is nothing to do with the opts.

---@type LazySpec
return {
  "nvim-neorg/neorg",
  build = ":Neorg sync-parsers",
  dependencies = { "nvim-lua/plenary.nvim" },
  ft = { "norg" },
  cmd = { "Neorg" },
  opts = {
    load = {
      -- https://github.com/nvim-neorg/neorg/wiki/Defaults
      ["core.defaults"] = {
        config = {
          disable = {
            "core.journal",
            -- "core.looking-glass",
          },
        },
      },
      -- https://github.com/nvim-neorg/neorg/wiki/Completion
      ["core.completion"] = {
        config = {
          engine = "nvim-cmp",
        },
      },
      -- https://github.com/nvim-neorg/neorg/wiki/Concealer
      ["core.concealer"] = {},
      -- https://github.com/nvim-neorg/neorg/wiki/Dirman
      ["core.dirman"] = {
        config = {
          workspaces = {
            notes = "~/notes",
          },
          default_workspace = "notes",
        },
      },
    },
  },
}

Actual behavior

LSPs and other language-specific tools dose not kick in so we have no lsp attached

image

Expected behavior

LSPs and other language-specific tools dose kick in so we have lsp attached and get correct completions

image

Steps to reproduce

  1. create a code block in .norg file
  2. run command: :Neorg keybind all core.looking-glass.magnify-code-block
  3. write code in the new created buffer

Potentially conflicting plugins

No response

Other information

No response

Help

Yes, but I don't know how to start. I would need guidance (check question below)

Implementation help

It seems that the following code caused the issue and after I fixed it locally, it works as the expected behavior showed above.

  1. code link: https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/ui/module.lua#L172
    context: we create a scratch buffer
    fixture: local buf = vim.api.nvim_create_buf(false, true) => local buf = vim.api.nvim_create_buf(false, false)
    extra: passthrough as a parameter of the function is a good idea
  2. code link: https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/ui/module.lua#L182
    context: buf name was started with neorg:// which does not exist at all
    fixture: vim.api.nvim_buf_set_name(buf, "neorg://" .. name) => vim.api.nvim_buf_set_name(buf, name)
    extra: passthrough as a parameter of the function is a good idea
  3. code link: https://github.com/nvim-neorg/neorg/blob/main/lua/neorg/modules/core/ui/module.lua#L188
    context: duplicate vim.api.nvim_win_set_buf with L183
    fixture: vim.api.nvim_win_set_buf(0, buf) => -- vim.api.nvim_win_set_buf(0, buf)
    extra: I do not know whether it is a mistake or a bug fix for other issue

I can submit a PR after the following questions are answered:

  1. Is it OK to passthrough parameters?
    --- Creates a new vertical split
    ---@param name string the name of the buffer
    ---@param config table a table of <option> = <value> keypairs signifying buffer-local options for the buffer contained within the split
    ---@param left boolean if true will spawn the vertical split on the left (default is right)
    ---@param name_prefix boolean whether add 'neorg://' prefix to the buffer name
    ---@param is_scratch_buffer boolean whether create a scratch buffer
    ---@return number?, number? #The buffer of the vertical split
    create_vsplit = function(name, config, left, name_prefix, is_scratch_buffer)
  1. Can wen safely comment the second vim.api.nvim_win_set_buf?
@taujiong taujiong added the bug Issues related to bugs. Please attach a severity, a priority and category with this label. label Oct 21, 2023
@simonhughxyz
Copy link

I'd also like to see a fix for this, has a PR been made with your patch or are there issues with it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues related to bugs. Please attach a severity, a priority and category with this label.
Projects
None yet
Development

No branches or pull requests

2 participants