-
-
Notifications
You must be signed in to change notification settings - Fork 159
feat(todos): support file-specific todo definitions #956
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
feat(todos): support file-specific todo definitions #956
Conversation
Support to overwrite the globally defined todo keywords with a file specific one. While emacs orgmode actually supports multiple todo keyword sequences, this implementation explicitly focuses on one sequence, because the plugin currently also supports only one sequence to be defined in the configuration. To support the full emacs functionality this needs to be extended 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.
Looks good as a starting point into this feature. There are few more usages of config:get_todo_keywords()
across mappings.lua
file where we can use the file level ones with self.files:get_current_file():get_todo_keywords()
.
Co-authored-by: Kristijan Husak <[email protected]>
Co-authored-by: Kristijan Husak <[email protected]>
@kristijanhusak I a trying to tackle a more fundamental issue, where I might need your help: The custom keywords are currently not correctly highlighted. I try to understand, how the highlighting of keywords works in general and why the custom keywords are currently ignored. Here a screenshot. Only From what I learned form the code, I have the gut feeling, that the highlight definitions are loaded with the start of the plugin and to highlight the custom words correctly those highlighting informations need to be updated, when a file is loaded. Is my hypothesis correct? Do you have a suggestion how to fix the issue? |
@seflue highlighting of the keywords is done through a custom ts predicate. Currently, it figures out if the match is a todo keyword by checking I assumed you want to do this in the next PR that's why I didn't mention it. vim.treesitter.query.add_predicate('org-is-todo-keyword?', function(match, _, source, predicate)
local node = match[predicate[2]]
node = node and node[#node]
if node then
--- Assume predicate have `self.files` instance of `OrgFiles`
--- I'm not sure if getting a buffer name can cause some performance issues, so we might need
--- to cache the bufnr -> org_file.
local todo_keywords = self.files:get(vim.api.nvim_buf_get_name(source)):get_todo_keywords()
local text = vim.treesitter.get_node_text(node, source)
return todo_keywords[text] and todo_keywords[text].type == predicate[3] or false
end
return false
end, { force = true, all = true })
|
@kristijanhusak I just found the code you mentioned and also saw, that some refactoring would be needed. Because it would be nice, if the highlighting updates on changing the |
I also integrated the feature to all mappings using |
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.
Looks good, thanks!
While emacs orgmode actually supports multiple todo keyword sequences, this implementation explicitly focuses on one sequence, because the plugin currently also supports only one sequence to be defined in the configuration.
To support the full emacs functionality this needs to be extended later.
Summary
Support to overwrite the globally defined todo keywords with a file specific one.
Related Issues
Related #
#250
Closes #
#185
Changes
#+todo:
when definedChecklist
I confirm that I have:
Conventional Commits
specification (e.g.,
feat: add new feature
,fix: correct bug
,docs: update documentation
).make test
.