Initial markdown support
Markdown doesnt have a language server, so do this manually Closes #43
This commit is contained in:
@@ -65,9 +65,7 @@ function M.get_position_navigation_direction()
|
||||
end
|
||||
end
|
||||
|
||||
function M.get_width_percentage()
|
||||
return M.options.width / 100
|
||||
end
|
||||
function M.get_width_percentage() return M.options.width / 100 end
|
||||
|
||||
function M.get_split_command()
|
||||
if M.options.position == 'left' then
|
||||
@@ -90,6 +88,7 @@ end
|
||||
|
||||
function M.is_client_blacklisted(client_id)
|
||||
local client = vim.lsp.get_client_by_id(client_id)
|
||||
if not client then return false end
|
||||
return has_value(M.options.lsp_blacklist, client.name)
|
||||
end
|
||||
|
||||
|
||||
37
lua/symbols-outline/markdown.lua
Normal file
37
lua/symbols-outline/markdown.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local M = {}
|
||||
|
||||
---Parses markdown files and returns a table of SymbolInformation[] which is
|
||||
-- used by the plugin to show the outline.
|
||||
-- We do this because markdown does not have a LSP.
|
||||
-- Note that the headings won't have any heirarchy (as of now).
|
||||
---@return table
|
||||
function M.handle_markdown()
|
||||
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||
local results = {}
|
||||
|
||||
for line, value in ipairs(lines) do
|
||||
if string.find(value, "^#+") then
|
||||
if #results > 0 then
|
||||
results[#results].selectionRange["end"].line = line - 1
|
||||
results[#results].range["end"].line = line - 1
|
||||
end
|
||||
|
||||
table.insert(results, {
|
||||
kind = 13,
|
||||
name = value,
|
||||
selectionRange = {
|
||||
start = {character = 1, line = line - 1},
|
||||
["end"] = {character = 1, line = line - 1}
|
||||
},
|
||||
range = {
|
||||
start = {character = 1, line = line - 1},
|
||||
["end"] = {character = 1, line = line - 1}
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return {[1000000]={result=results}}
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -7,4 +7,8 @@ function M.is_buf_attached_to_lsp(bufnr)
|
||||
return clients ~= nil and #clients > 0
|
||||
end
|
||||
|
||||
function M.is_buf_markdown(bufnr)
|
||||
return vim.api.nvim_buf_get_option(bufnr, 'ft') == 'markdown'
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user