Skip to content

Markdown language server with advanced linking and syntax features to support any PKM system. It's completely compatible Obsidian markdown syntax and aims to replace and extend the Obsidian editor. It is primarily an Obsidian Language Server.

License

sQVe/markdown-oxide

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Markdown Oxide

Implementing obsidian PKM features (and possibly more) in the form of a language server allows us to use these features in our favorite text editors and reuse other lsp related plugins (like Telescope, outline, refactoring tools, ...)

Usage

==I am trying to get this into package distributions right now!!! This should be easier soon==

First, compile the plugin. Clone the repo and then run cargo build --release

Next, follow the directions for your editor

VSCode

Go to the vscode extension readme and run the commands listed

Neovim

Make sure rust is installed properly and that you are using nvim cmp (I am not sure if it works in other completion engines)

Adjust your neovim config as follows

local configs = require("lspconfig.configs")
configs["obsidian_ls"] = {
default_config = {
  root_dir = function() return vim.fn.getcwd() end,
  filetypes = {"markdown"},
  cmd = {"{path}"} -- replace {path} with the path to the --release build. 
  -- {path} will be {where ever you cloned from}/obsidian-ls/target/release/markdown-oxide
},
on_attach = on_attach, -- do this only if you have an on_attach function already
}
require("lspconfig").obsidian_ls.setup({
    capabilities = capabilities -- ensure that capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true
})

then adjust your nvim-cmp source settings for the following. Note that this will likely change in the future.

{
    name = 'nvim_lsp',
         option = {
             obsidian_ls = {
                 keyword_pattern = [[\(\k\| \|\/\|#\)\+]]
             }
         }
},

I also recommend enabling codelens in neovim. Add this snippet to your on_attach function for nvim-lspconfig

-- refresh codelens on TextChanged and InsertLeave as well
vim.api.nvim_create_autocmd({ 'TextChanged', 'InsertLeave', 'CursorHold', 'LspAttach' }, {
    buffer = bufnr,
    callback = vim.lsp.codelens.refresh,
})
-- trigger codelens refresh
vim.api.nvim_exec_autocmds('User', { pattern = 'LspAttached' })
  1. Test it out! Go to definitions, get references, and more!

NOTE: To get references on files, you must place your cursor/pointer on the first character of the first line of the file, and then get references. (In VSCode, you can also use the references code lens)

Note on Linking Syntax

The linking syntax is that of obsidian's and can be found here https://help.obsidian.md/Linking+notes+and+files/Internal+links

Generally, this is [[relativeFilePath(#heading)?(|display text|)?]] e.g. [[articles/markdown oxide#Features|Markdown Oxide Features]] to link to a heading in Markdown Oxide.md file in the articles folder or [[Obsidian]] for the Obsidian.md file in the root folder.

Features

  • Go to definition (or definitions) from ...
    • File references [[file]]
    • Heading references [[file#heading]]
    • Block references. [[file#^index]] (I call indexed blocks the blocks that you directly link to. The link will look like [[file#^index]]. When linking from the obsidian editor, an index ^index is appended to the paragraph/block you are referencing)
    • Tags #tag and #tag/subtag/..
    • Footnotes: "paraphrased text[^footnoteindex]"
    • Metadata tag
  • Get references
    • For File when cursor is on the first character of the first line of the file. This will produce references not only to the file but also to headings and blocks in the file
    • For block when the cursor is on the blocks index "...text ^index"
    • For tag when the cursor is on the tags declaration. Unlike go to definition for tags, this will produce all references to the tag and to the tag with subtags
    • Footnotes when the cursor is on the declaration line of the footnote; [^1]: description...
  • Completions (requires extra nvim cmp config; follow the directions above)
    • File link completions
    • Heading link Completions
    • Subheading compeltions in the form [[file#heading#subheading]] from https://help.obsidian.md/Linking+notes+and+files/Internal+links#Link+to+a+heading+in+a+note (Note: right now you can link to subheadings through [[file#subheading]])
    • Block link completions (searches the text of the block)
    • Footnote link completions
    • New Block link Completions through grep: to use this, type [[ , and after you press space, completions for every block in the vault will appear; continue typing to fuzzy match the block that you want; finally, select the block; a link will be inserter to the text document and an index (ex ^1j239) will be appended to the block in its respective file
    • Callout/admonition completions
    • Metadata completions
    • Dataview completions
    • Metadata tag completions
    • ```query``` code block completions
  • Hover Preview
    • File
    • Headings
    • Indexed Blocks
    • Footnotes
  • Code Actions
    • Unresolved file link -> Create the file
    • Unresolved heading link -> append heading to file and create file
    • Link suggestions (by text match or other)
    • Refactoring: Move headers or selections to a new file
    • Link an unlinked reference
    • Link all unlinked references to a referenceable
  • Diagnostics
    • Unresolved reference
    • Unlinked reference
  • Symbols
    • File symbols: Headings and subheadings
    • Workspace headings: everythign linkable: files, headings, tags, ... Like a good search feature
    • Lists and indented lists
  • Rename
    • File (cursor must be in the first character of the first line)
    • Headings
    • Tags
    • Indexed Blocks
  • Dataview support
  • Take some influence from LogSeq!!!!! https://docs.logseq.com/#/page/start%20here
    • Support Logseq syntax and completions/parsing for block references
    • Support Logseq embeds
    • Support Completions for logseq tasks
    • Support https://docs.logseq.com/#/page/markdown
    • Influence from logseq shortcut completions; such as to dates like /tomorrow

Alternatives

I love open source and all open source authors!! I also believe healthy competition is good! Moxide is competing with some alternatives, and I want to make it the best at its job!!

Here are the alternatives (open source authors are welcom to make PRs adding their projects here!)

---The--bottom--line--------------------------------------------------------

Listen. I really like vim motions. I also really like low latency terminal editing. I very much so also like my neovim plugins and config. And wow I also like using obsidian (and other md apps). Can't I just have it all??? Can't I brute text edit in neovim and preview and fine edit in the JS madness? Well, I thought I could; that is why I am making this.

About

Markdown language server with advanced linking and syntax features to support any PKM system. It's completely compatible Obsidian markdown syntax and aims to replace and extend the Obsidian editor. It is primarily an Obsidian Language Server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 94.5%
  • TypeScript 5.1%
  • Other 0.4%