-
Notifications
You must be signed in to change notification settings - Fork 69
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
Support multi-filetype wikis with g:wiki_link_creation #299
Conversation
This option provides a more flexible filetype dependent behaviour. It also deprecates four other options and thus makes configuring wiki.vim easier for most people. And since the new option provides sensible defaults, it also means most people will require less customization. The following options are deprecated: * g:wiki_map_text_to_link * g:wiki_map_create_page * g:wiki_link_extension * g:wiki_link_target_type refer: #296
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.
Seems to be all good. But, as I was testing, I've found a strange bug where I can modify values in g:wiki_link_creation
because it says that I'm trying to index a nil value.
INFO
- version: NVIM v0.9.0
- OS: MacOS Ventura
- Package manager: Paq (uses vim's default package management)
What I've wrote:
-- lua
vim.g.wiki_link_creation.adoc.url_transform = function(x) return { x:lower():gsub(' ', '-'), x } end
" viml
let g:wiki_link_creation.adoc.url_transform = { x -> substitute(tolower(x), '\s\+', '-', 'g') }
error
Error detected while processing /Users/sacca/Repos/dot/config/nvim/init.lua:
E5113: Error while calling lua chunk: /Users/sacca/Repos/dot/config/nvim/init.lua:112: attempt to index field 'wiki_link_creation' (a nil value)
stack traceback:
/Users/sacca/Repos/dot/config/nvim/init.lua:112: in main chunk
I've tried:
- calling variable from Lua with
vim.g
table - using a viml file in
plugin
directory same problem - using a viml file in
after/plugin
directory same problem - calling viml with neovim
vim.cmd
function same problem - changing the variable within command mode worked
Ah, yes, I believe your problem is that you are trying to set a key of the option before the option was fully defined. wiki.vim will define the default options when it is defined (it will not override user settings, though). But if you are trying to set options before wiki.vim is loaded, then you must define the entire dictionary. Since wiki.vim merges user options with the default, I believe the following should suffice: vim.g.wiki_link_creation = {
adoc = {
url_transform = function(x) return x:lower():gsub(' ', '-') end
}
} let g:wiki_link_creation = {
\ 'adoc': {
\ 'url_transform': { x -> substitute(tolower(x), '\s\+', '-', 'g') }
\ }
\} I.e., the |
Oh, and thanks for testing! Do you have any thoughts on the choice of names?
Hmm. I believe one or more of these should work. It all depends on the load order, which you can inspect with However, if you are lazy loading wiki.vim, then this might not work. But then my previous suggestion of defining the entire dictionary should work. |
I think there are very clear. I like this changes a lot. The only thing is figuring out this issue and document it. When I'm at home i will test your suggestions |
Thanks, I appreciate that! Perhaps we need to clarify something in the docs here. PS! I will create some new issue with feature requests based on our other discussion. I'll try to make some "specs" and you if you want to take a shot at one of them, feel free. I advice that you let me know first, just to avoid that we work on the same thing in parallell. |
This did it. |
I've now released v0.7 with an announcement. I'll therefore not mind merging these new changes. I believe this PR is ready to merge. Or did I miss anything? If I don't hear any objections I'll merge probably tomorrow. |
From my part I don't see any errors/bugs. |
See the discussion in #296. This PR implements a first version of the proposed
g:wiki_link_creation
.The new option provides a more flexible filetype-dependent behaviour. It deprecates four other options and makes configuring wiki.vim easier for most people. Since the new option provides sensible defaults, it also means most people will require less customization.
The following options are deprecated as the related features are all now more flexibly controlled by
g:wiki_link_creation
: