Coder Social home page Coder Social logo

feel-ix-343 / markdown-oxide Goto Github PK

View Code? Open in Web Editor NEW
575.0 3.0 10.0 21.89 MB

Editor Agnostic PKM: you bring the text editor and we bring the PKM - inspired by and compatible with Obsidian

License: Creative Commons Zero v1.0 Universal

Rust 88.45% JavaScript 0.20% TypeScript 11.29% Shell 0.06%
language-server-protocol lsp lsp-server markdown obsidian obsidian-md rust rust-lang rust-language-server vscode-language-support

markdown-oxide's Introduction

markdown-oxide's People

Contributors

feel-ix-343 avatar jlin avatar ksaiakshit avatar sqve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

markdown-oxide's Issues

[Bug] Completion does not work for markdown files inside folder

reference: #24
Without folder (both current file and file cta.md in root folder of workspace),

image

With folder (both current file and file cta.md in pages subfolder of workspace),

image

LspInfo

 Detected filetype:   markdown
 
2 client(s) attached to this buffer: 
 

 Client: markdown_oxide (id: 3, bufnr: [2])
 	filetypes:       markdown
 	autostart:       true
 	root directory:  /Users/rayx/obsidian
 	cmd:             /Users/rayx/bin/markdown-oxide
 

NeoVim / Mason / Windows 11: The current platform is unsupported

Installing binary on Intel / Windows 11 / 64bit with

:MasonInstall markdown-oxide

fails with

  Failed
    ◍ markdown-oxide
      ▼ Displaying full log
        The current platform is unsupported.

this is because in the Mason registry (do you have access to it?) it is tagged with

    "source": {
      "id": "pkg:github/feel-ix-343/[email protected]",
      "asset": [
        {
          "target": "win_x86",
          "file": "markdown-oxide-{{version}}-x86_64-pc-windows-gnu.zip",
          "bin": "markdown-oxide-{{version}}-x86_64-pc-windows-gnu/markdown-oxide.exe"
        }
      ]
    },

which means 32-bit but filename says ...-x86_64-... and will be 64 bit. Target has to be changed to win_x64 in the registry definition!

Meanwhile we can use

:MasonInstall --target=win_x86 markdown-oxide

Using in Helix fails without Git initialized

Hi there, this is a really neat project and I appreciate your efforts!

I'm not sure if this is intentional, a quirk of Helix, etc., but I thought it might be worth reporting that, at least in MacOS with Helix v24.3, this language server doesn't work without a .git root to, as far as I know, establish a workspace.

creating files consistent with obsidian structure

Obsidian allows users to specify where dailyNotes, templates etc are stored.

currently configuration doesn't allow to replicate same structure. As it allows creating files, there should be some config to allow users to define file placement (esp. dailynotes)

I realise this doesn't fall under the purview of a lsp but I could think of alternate solution than to include a config in lsp.

Gives error in my (larger) Obsidian vault

I have two Obsidian vaults – one smaller, one larger. markdown-oxide works fine in the smaller one, but in the larger one, I get this error in nvim:

Error executing vim.schedule lua callback: /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1308: RPC[Error] code_name = InvalidParams, message = "Invalid params"
stack traceback:
        [C]: in function 'assert'
        /usr/local/share/nvim/runtime/lua/vim/lsp.lua:1308: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

I don't really understand what's the problem though.

What can I do to debug this? I built it with cargo from this commit: 2c57711 , I'm using NVIM v0.9.5 with these settings:

local capabilities = vim.lsp.protocol.make_client_capabilities()
lspconfig['markdown_oxide'].setup({
    capabilities = capabilities,
    on_attach = on_attach,
})

(on_attach is a pretty long function)

Formatting does not accept nested Todos

Hello!

Love the LSP! Use it all the time for Obsidian and it works great for almost everything.

I have format on save in my Nvim config right now, and I had to disable that for markdown files because it causes my nested Todos to be broken into multiple lines.

So if I have something like this:

- [ ] Some todo
   - [ ] A nested todo

The formatting will add a line break between my todos (and even move the todo back a little, but not fully).

It will end up something like this:

- [ ] Some todo

 - [ ] A nested todo

EDIT: That will not happen if I have more todos underneath that. Or if I have multiple nested layers.
Like so:

- [ ] Some todo
   - [ ] A nested todo
- [ ] Another todo

EDIT2: What an edge case, apparently, it needs to have another todo further down to "draw" the todo from it's parent:

This will cause it to happen:

- [ ] Some todo
   - [ ] A nested todo

- [ ] Another todo

Fix performance issues

I have been noticing that completions and semantic tokens are quite slow on my vault.

Add `cargo-binstal` support

I find cargo-binstall helpful when downloading cargo binaries, at least much faster than wget or cargo install. It would be great to integrate it into markdown-oxide. I could submit a PR if you are fine with it!

Tag definition

I am sorry I am bringing this up again. I have noticed a small bug when parsing tags.

According to the Obsidian manual, a tag is defined this way:

Tag format

You can use any of the following characters in your tags:

  • Alphabetical letters
  • Numbers
  • Underscore (_)
  • Hyphen (-)
  • Forward slash (/) for Nested tags

Tags must contain at least one non-numerical character. For example, #1984 isn't a valid tag, but #y1984 is.

When I use tag auto-completion, I get this:

screenshot-1713774068

It seems parsing only tests for at least one non-numerical character between # and a space. That is why #2024 is parsed correctly as a non-tag, but not the links. Those tags include the full URL. #7 wouldn't be a tag, but if we include ] and the rest as valid characters for a tag name, we end up with the tag shown in the dialogue. The same goes for #seven.

The tree-sitter markdown parser considers this a tag:

_tag_name: $ => seq($._word_no_digit, repeat(choice($._word_no_digit, $._digits, '-'))),

that means after the # there cannot be a digit as first character, but then they are allowed, so #y1984 is valid, but #1984y isn't.

So I think the regular expression needs some tweaking, something like:

/(^| )+#[a-zA-Z_\-\/][0-9a-zA-Z_\-\/]*/

screenshot-1713777330

I don't know about #-/_/tag, but it doesn't seem the spec rejects it. Maybe you prefer to tweak the first part so the first character doesn't include _-/ either.

Thank you!

consistent follow link via <c-]>

I notice that currently <c-]> can follow the link to file under cursor. However this throws No tags file error when link is not resolved.

Proposed behaviour: when link in unresolved, <c-]> creates the file and then opens it.

personally I'd prefer gf command, that is more accessible.

Unresolved Reference warning for relative path

If I don't add ./ before a link to a local image file, it shows the warning. Could you please also support this format? Current behavior:

![](img/2024-04-17-15-14-12.png)

shows warning.

![](./img/2024-04-17-15-14-12.png)

no warning.

Tag completion support

Hi, thank you for the great LSP server! It is really fast, and I am hoping it will provide a full solution for markdown/obsidian editing in Neovim. I have been using it for a couple of weeks, and there are two things I find missing:

  1. Tag auto-completion: I use tags extensively, and marksman and obsidian.nvim both have tag auto-completion. I understand it should be a relatively easy addition, as moxide already supports go to tag definitions and references, so they are parsed.

  2. Bug: I think moxide parses anything starting by # as a section-type entry. However, it doesn't check whether the symbol happens within a code block. For example, when I ask for document symbols for this small document (sh fenced code block), I get comment lines as sections.

# Real Section

# Just a comment
cd ..

I would get both Real Section and Just a comment as document symbols instead of just Real Section.

Thank you very much for your work.

Windows 10+VSCode: Markdown Oxide client: couldn't create connection to server.

After installing the markdown-oxide extension on VSCode, it fails to start the language server:

[Error - 10:41:30 AM] Markdown Oxide client: couldn't create connection to server.
Error: Unsupported server configuration {
    "command": null
}
    at c:\Users\user\.vscode\extensions\felixzeller.markdown-oxide-1.0.4\client\node_modules\vscode-languageclient\lib\node\main.js:466:35
    at LanguageClient.createConnection (c:\Users\user\.vscode\extensions\felixzeller.markdown-oxide-1.0.4\client\node_modules\vscode-languageclient\lib\common\client.js:1144:28)
    at LanguageClient.start (c:\Users\user\.vscode\extensions\felixzeller.markdown-oxide-1.0.4\client\node_modules\vscode-languageclient\lib\common\client.js:681:32)

Building markdown-oxide and setting it in the path solves the problem

[feat] code completion for wiki links to headline

e.g. [[another-notes#_]] when cursor on _, it should list all headlines in another-notes, bellow is marksman behavior

image

While oxide treats # inside a wiki link as tag, so the result is a bit confusing

image

Workspace symbols for daily notes

One of my most used operations (as a longtime vimwiki user moving over to Obsidian) is to open a daily note. I really like the ability to use today, tomorrow, etc. to link to the daily note for the corresponding day and would like a corresponding way to open daily notes.

Would it be possible to also add today, tomorrow, etc. as workspace symbols, or otherwise add a command to open these notes?

Add git install to readme

Thanks for this project.
Most people might know but I would add the following option to the readme:

install from git

cargo install --git https://github.com/Feel-ix-343/markdown-oxide.git markdown-oxide

Some bugs / feature requests

  • manual invokation of completion in certain cases (e.g. callouts) : Sometimes suggestion is not needed, one should be able to manually invoke suggestion (as in omnifunc) for lesser uses features that could be triggered more often.
  • custom callouts
  • Calling Telescope lsp_buf_references directly jumps to file (likely has only one reference). I expected a telescope picker.
  • show old name while renaming (already shown for some)

Plugin works flawlessly otherwise. Just for peace of mind, wanted to ask if texts, headings, filenames etc are being indexed somewhere for easy searching.

Also, a heavier operation, block completion could be manually invoked after typing ^ (similar to obsidian's feature)

Apologies for mixing everything up. Feel free to pick ones actionable and close this issue.

[Neovim]: lspconfig cannot access configuration for markdown_oxide

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!

Permission denied trying to create files in a Google Drive folder

I'm getting this error when using the code action to create new files

image

2024-04-17T15:41:35-03:00 [INFO] starting language server "markdown-oxide", path: "/Users/[REDACTED]/Library/CloudStorage/GoogleDrive-[REDACTED]/My Drive/Notes", id: 28
2024-04-17T15:41:35-03:00 [INFO] starting language server. binary path: "/Users/[REDACTED]/Library/Application Support/Zed/extensions/work/markdown-oxide/markdown-oxide-v0.0.16/markdown-oxide-v0.0.16-aarch64-apple-darwin/markdown-oxide", working directory: "/Users/[REDACTED]/Library/CloudStorage/GoogleDrive-[REDACTED]/My Drive/Notes", args: []
2024-04-17T15:41:41-03:00 [ERROR] crates/editor/src/element.rs:324: Permission denied (os error 13)

Broken Pipe, using in Helix

Hello again! After adding that git root I start to get completions, but only for the file I'm currently in :-)

Checking Helix's logs, they write of a broken pipe. I'd like to help looking into this when I have a little time, but I'm not sure when that will be so I figured I could at least report it.

2024-04-10T23:08:17.900 helix_lsp::client [WARN] language server failed to terminate gracefully - server closed the stream
2024-04-10T23:08:17.900 helix_lsp::transport [ERROR] markdown-oxide err: <- StreamClosed
2024-04-10T23:08:17.900 helix_lsp::transport [ERROR] markdown-oxide err: <- IO(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" })

Add config options

  • Link Paths: Shortest past or relative path for markdown links and wikilinks; Related to #2 and #18

Failed to start in nvim nightly

Thanks for the project. I am trying to move from marksman to oxide project with nvim
But with latest nvim nightly and lspconfig. The lsp server failed to start.
If I run lspconfig.markdown_oxide.setup{}, I have following errors

Error executing vim.schedule lua callback: ...software/nvim-nightly/share/nvim/runtime/lua/vim/lsp.lua:1431: RPC[Error] code_name = InvalidParams, 
message = "Invalid params"
stack traceback:
        [C]: in function 'assert'
        ...software/nvim-nightly/share/nvim/runtime/lua/vim/lsp.lua:1431: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Are there anything must be setup for this lsp?

Creating a new link also adds the name of the folder

I am a veteran Obsidian user and have the option New link format set to Shortest path when possible in it.

When I use moxide, on inserting a link that is in a subfolder, moxide also adds the folder name to the link.
Is there a way to turn this off?

Coq_nvim as the autocompletion tool

TY for the amazing job I would like to ask if it is possible to use the auto completion features without hrsh7th/nvim-cmp and with ms-jpq/coq_nvim. I have done everything except adding the source

{
name = 'nvim_lsp',
  option = {
    markdown_oxide = {
      keyword_pattern = [[\(\k\| \|\/\|#\)\+]]
    }
  }
},
Screenshot 2024-04-29 at 11 13 21

In my configs as I don't use nvim-cmp and I am pretty close to a fully working functionality( see the screenshot)
So I was wondering if we can communicate to ms-joq and add markdown-oxide as a third party source.

In the next days I will try to manually add it and provide some configs. The next best thing other than supporting it out of the box is to document the required work to support it.

Question: Feature parity with Marksman

Hey,

I've been trying this LSP out, coming from Marksman, and it's working great in certain cases but not in others. I have followed the recommended setup, but I still cannot get go-to definitions / references to work. Some of the basic LSP features that Marksman provides are missing

Have I set something up incorrectly, or is this currently broken? The roadmap lists most of these things as supported, which makes me confused.

🍻

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.