-
-
Notifications
You must be signed in to change notification settings - Fork 143
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
Nested link and orphan characters #431
Closed
Closed
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
052cb8f
partial implementation of nested markup in links.
gzagatti 68f5d43
deal with orphan markups.
gzagatti a5024f7
linting.
gzagatti 08d0c73
alternate orphan.
gzagatti b8ef244
deal with orphaned markups.
gzagatti 91669e5
Add level and is_archived to OrgHeadline (#437)
joaomsa 7ec04ca
[docgen] Update doc/orgmode_api.txt
invalid-email-address 7cc01f4
Calendar next/prev supports count prefix (#438)
jgollenz c9889c6
Merge remote-tracking branch 'origin/master' into nested-link
gzagatti 824aa58
fix issues merging with master.
gzagatti 8463554
fix merge issues part ii.
gzagatti 9c8073f
Merge remote-tracking branch 'origin/master' into nested-link
gzagatti 0b7d984
do not set foldlevel in ftplugin
gzagatti 377a823
Merge remote-tracking branch 'origin/master' into nested-link
gzagatti e90e31e
uses treesitter fold from neovim instead
gzagatti 2513880
fix injection language, allow spell highlight
gzagatti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,10 +20,10 @@ function! OrgmodeFormatExpr() | |
endfunction | ||
|
||
setlocal nomodeline | ||
setlocal fillchars+=fold:\ | ||
setlocal foldmethod=expr | ||
setlocal foldexpr=nvim_treesitter#foldexpr() | ||
setlocal foldtext=OrgmodeFoldText() | ||
" setlocal fillchars+=fold:\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be uncommented |
||
" setlocal foldmethod=expr | ||
" setlocal foldexpr=nvim_treesitter#foldexpr() | ||
" setlocal foldtext=OrgmodeFoldText() | ||
setlocal formatexpr=OrgmodeFormatExpr() | ||
setlocal omnifunc=OrgmodeOmni | ||
setlocal commentstring=#\ %s | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,6 +213,15 @@ local function load_deps() | |
vim.treesitter.query.add_predicate('org-is-valid-latex-range?', is_valid_latex_range) | ||
end | ||
|
||
-- a function that splits a string on '.' | ||
local function split(string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a |
||
local t = {} | ||
for str in string.gmatch(string, '([^.]+)') do | ||
table.insert(t, str) | ||
end | ||
return t | ||
end | ||
|
||
---@param bufnr number | ||
---@param line_index number | ||
---@return table | ||
|
@@ -221,18 +230,20 @@ local get_matches = ts_utils.memoize_by_buf_tick(function(bufnr, line_index, roo | |
local taken_locations = {} | ||
|
||
for _, match, _ in query:iter_matches(root, bufnr, line_index, line_index + 1) do | ||
for _, node in pairs(match) do | ||
for id, node in pairs(match) do | ||
local char = node:type() | ||
-- saves unnecessary parsing, since \\ is not used below | ||
if char ~= '\\' then | ||
local range = ts_utils.node_to_lsp_range(node) | ||
local linenr = tostring(range.start.line) | ||
taken_locations[linenr] = taken_locations[linenr] or {} | ||
local capture = split(query.captures[id])[2] | ||
if not taken_locations[linenr][range.start.character] then | ||
table.insert(ranges, { | ||
type = char, | ||
range = range, | ||
node = node, | ||
capture = capture, | ||
}) | ||
taken_locations[linenr][range.start.character] = true | ||
end | ||
|
@@ -248,7 +259,8 @@ local get_matches = ts_utils.memoize_by_buf_tick(function(bufnr, line_index, roo | |
end) | ||
|
||
local seek = {} | ||
local seek_link = {} | ||
local seek_link = nil | ||
local orphans = {} | ||
local result = {} | ||
local link_result = {} | ||
local latex_result = {} | ||
|
@@ -315,23 +327,33 @@ local get_matches = ts_utils.memoize_by_buf_tick(function(bufnr, line_index, roo | |
to = item.range, | ||
}) | ||
else | ||
seek[item.type] = item | ||
nested[#nested + 1] = item.type | ||
can_nest = markers[item.type].nestable | ||
if not (orphans[item.type] and item.capture == 'end') then | ||
seek[item.type] = item | ||
nested[#nested + 1] = item.type | ||
can_nest = markers[item.type].nestable | ||
orphans[item.type] = nil | ||
end | ||
orphans[item.type] = nil | ||
end | ||
else | ||
orphans[item.type] = item.capture | ||
end | ||
end | ||
|
||
if item.type == '[' then | ||
if item.type == '[' and can_nest then | ||
seek_link = item | ||
nested[#nested + 1] = item.type | ||
can_nest = false | ||
end | ||
|
||
if item.type == ']' and seek_link then | ||
table.insert(link_result, { | ||
from = seek_link.range, | ||
to = item.range, | ||
}) | ||
nested[#nested] = nil | ||
seek_link = nil | ||
can_nest = true | ||
end | ||
end | ||
|
||
|
@@ -401,7 +423,7 @@ local function apply(namespace, bufnr, line_index) | |
vim.api.nvim_buf_set_extmark(bufnr, namespace, link_range.from.start.line, link_range.from.start.character + 2, { | ||
ephemeral = true, | ||
end_col = link_range.from.start.character - 1 + link_end, | ||
spell = false, | ||
spell = true, | ||
}) | ||
|
||
vim.api.nvim_buf_set_extmark(bufnr, namespace, link_range.from.start.line, link_range.to['end'].character - 2, { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
(block parameter: (expr) @language (contents) @content) | ||
(block parameter: (expr) @injection.language (contents) @injection.content (#set! injection.include-children)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets leave all these highlight changes for a separate PR.