Feel-ix-343 / markdown-oxide

Editor Agnostic PKM: you bring the text editor and we bring the PKM - inspired by and compatible with Obsidian
GNU General Public License v3.0
684 stars 10 forks source link

[Neovim]: lspconfig cannot access configuration for markdown_oxide #78

Closed Tibor5 closed 1 month ago

Tibor5 commented 1 month ago

Hey there!

I installed markdown-oxide via cargo and I'm trying to set it up for Neovim via lspconfig as per the instructions in the README.

However, on Neovim startup, I get the following message:

[lspconfig] Cannot access configuration for markdown_oxide. Ensure this server is listed in server_configurations.md or added as a custom server.

Of course, it is listed in the lspconfig's server_configuration.md since that's where I found instructions on how to set it up.

This is my LSP configuration (with lazy.nvim):

  {
    "neovim/nvim-lspconfig",
    dependencies = { "williamboman/mason-lspconfig.nvim", "hrsh7th/cmp-nvim-lsp" },
    opts = {
      diagnostics = require("core.diagnostics"),
      inlay_hints = { enabled = true },
      autoformat = false,
      capabilities = {
        textDocument = {
          documentFormattingProvider = false,
          codelens = { enable = true },
          completion = {
            completionItem = {
              snippetSupport = true,
              resolveSupport = { properties = { "documentation", "detail", "additionalTextEdits" } },
            },
          },
        },
      },
    },
    config = function(_, opts)
      local lspconfig = require("lspconfig")
      local mason_lspcfg = require("mason-lspconfig")
      local has_cmp, lspcmp = pcall(require, "cmp_nvim_lsp")
      local lsp_attach = F.LspAttach
      vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
      local capabilities = vim.tbl_deep_extend(
        "force",
        {},
        has_cmp and lspcmp.default_capabilities(vim.lsp.protocol.make_client_capabilities()) or {},
        opts.capabilities or {}
      )
      mason_lspcfg.setup({ ensure_installed = vim.tbl_keys(opts.servers) })
      local capabilities_oxide = capabilities
      capabilities_oxide.workspace = { didChangeWatchedFiles = { dynamicRegistration = true } }

      lspconfig.markdown_oxide.setup({
        on_attach = lsp_attach,
        capabilities = capabilities_oxide,
        filetypes = { "markdown" },
        root_dir = lspconfig.util.root_pattern(".git", ".obsidian", ".moxide.toml", "*.md"),
        single_file_support = true,
        cmd = { "markdown-oxide" },
      })
    end
  }

I would appreciate it if anyone could point me in the right direction for debugging this further.

Thank you!

Feel-ix-343 commented 1 month ago

Hey!

Could you try updating nvim-lspconfig?

Tibor5 commented 1 month ago

Thank you for the swift reply :)

I tried updating nvim-lspconfig but it seems that nothing changed -- I still see the same error.

For additional context: I also use obsidian.nvim, markdown-preview.nvim and I disabled marksman LSP.

Would installing markdown-oxide from another source (cargo source instead of binary or AUR) make a difference?

Theoretically it shoulddn't make a difference right?

Feel-ix-343 commented 1 month ago

Great though but that should not matter.

The setup looks good, but I'm wondering if you are calling .setup from different contexts. Does the language server work by any chance? You could test completions and such.

Feel-ix-343 commented 1 month ago

Also the *.md pattern is very interesting; I want to see if this works!

Tibor5 commented 1 month ago

Regarding your thoughts on calling setup from different contexts, It's not; it's only called once on startup when lspconfig is set up along with all the specified servers.

I tried running markdown-oxide binaries from different installation sources, but nothing changed.

The language server does not work since it's not set up by lspconfig—it only returns the error that I mentioned above: it cannot find the configuration for markdown-oxide. Running :LspInfo shows there is no markdown_oxide set up.

Edit: running markdown-oxide from the command line also does nothing; it just hangs and waits until it is cancelled. I don't know whether that's desired.

Regarding the *.md pattern: I stole that from Ruff LSP for Python :) I use it for a few other servers like OCaml and it seems to work just fineTM Also see this link

Feel-ix-343 commented 1 month ago

Thanks for the links!

This issue is just really odd because I am positive that markdown_oxide is in the current version of nvim-lspconfig. This leads me to believe this must be a versioning issue

Would you mind posting you neovim version and lspconfig version?

I appreciate how responsive you are being too!

Tibor5 commented 1 month ago

Agree, it is weird.

nvim-lspconfig from lazy.nvim:

    ● nvim-lspconfig 13.84ms  BufReadPost
        dir     /home/user/.local/share/nvim/lazy/nvim-lspconfig
        url     https://github.com/neovim/nvim-lspconfig
        version 0.1.7
        tag     v0.1.7
        branch  master
        commit  cf3dd4a
        readme  README.md
        help    |lspconfig.txt|
        help    |lspconfig-all|
        event    BufReadPost  BufNewFile 

Neovim:

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1713773202

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim

I hope that this helps

Feel-ix-343 commented 1 month ago

Hey so cf3dd4a is roughly 5 months old which is far before markdown-oxide was added to nvim-lspconfig.

I am not sure why Lazy is not updating the plugin, but that is surely the issue.

I hope you are able to figure it out!

Feel-ix-343 commented 1 month ago

I looked through your neovim config too; it looks very organized!

Tibor5 commented 1 month ago

Great find! I completely missed it. Thank you very much for helping me out! That was the issue, using the master branch fixed it.

And thank you for the compliment, I appreciate it! :) If there's anything you like from my Dotfiles, feel free to use it.

Case closed.

Feel-ix-343 commented 1 month ago

🎉