Closed pkazmier closed 3 months ago
This is the actual table for headings.
require("markview").setup({
heading = {
enable = true,
shift_width = 4,
heading_1 = {},
heading_2 = {},
heading_3 = {},
heading_4 = {},
heading_5 = {},
heading_6 = {}
}
});
What you are showing should be inside the heading_1
(and all the other headings if you are configuring them too).
I will update the wiki to be more clear.
Check this table it has everything configured(it is used in the screenshot).
You can see how I did it.
Sorry if I was not clear, I do understand the top-level configuration and had the block of code in the right location. In addition, I had also discovered that table you shared, but even that configuration does not work for me as I get this error:
E5108: Error executing lua vim/_editor.lua:0: nvim_exec2()..BufWinEnter Autocommands for "<buffer=3>": Vim(append):Error executing lua callback: .
..te/pack/deps/opt/markview.nvim/lua/markview/renderer.lua:586: attempt to call field 'position' (a nil value)
stack traceback:
...te/pack/deps/opt/markview.nvim/lua/markview/renderer.lua:586: in function 'render_headers'
...te/pack/deps/opt/markview.nvim/lua/markview/renderer.lua:1153: in function 'render'
...m/site/pack/deps/opt/markview.nvim/ftplugin/markdown.lua:43: in function <...m/site/pack/deps/opt/markview.nvim/ftplugin/markdown.lua:2
9>
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
...ivim/site/pack/deps/start/mini.nvim/lua/mini/starter.lua:1528: in function 'eval_fun_or_string'
...ivim/site/pack/deps/start/mini.nvim/lua/mini/starter.lua:908: in function 'eval_current_item'
[string ":lua"]:1: in main chunk
stack traceback:
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
...ivim/site/pack/deps/start/mini.nvim/lua/mini/starter.lua:1528: in function 'eval_fun_or_string'
...ivim/site/pack/deps/start/mini.nvim/lua/mini/starter.lua:908: in function 'eval_current_item'
[string ":lua"]:1: in main chunk
And here is the config I tried:
require("markview").setup({
modes = { "n", "i" },
headings = {
enable = true,
shift_width = 0,
heading_1 = {
style = "label",
padding_left = " ",
padding_right = " ",
corner_right = "",
corner_right_hl = "decorated_h1_inv",
hl = "decorated_h1",
},
heading_2 = {
style = "label",
padding_left = " ",
padding_right = " ",
corner_right = "",
corner_right_hl = "decorated_h2_inv",
hl = "decorated_h2",
},
heading_3 = {
style = "label",
padding_left = " ",
padding_right = " ",
corner_right = "",
corner_right_hl = "decorated_h3_inv",
hl = "decorated_h3",
},
heading_4 = {
style = "label",
padding_left = " ",
padding_right = " ",
corner_right = "",
corner_right_hl = "decorated_h4_inv",
hl = "decorated_h4",
},
heading_5 = {
style = "label",
padding_left = " ",
padding_right = " ",
corner_right = "",
corner_right_hl = "decorated_h5_inv",
hl = "decorated_h5",
},
heading_6 = {
style = "label",
padding_left = " ",
padding_right = " ",
corner_right = "",
corner_right_hl = "decorated_h6_inv",
hl = "decorated_h6",
},
})
Also, I'm using main branch as I saw you merged the dev branch to it.
Ah, that one's a bug. My bad
Can you check now?
No more errors. Looks like I just need to define those decorated highlight groups now. Thanks!
Yeah, just saw that as well. It's looking great now:
Just need to find out what happened to my code block background, but that's easy enough. Thanks again!
Hmm ... I see when I defined those highlight groups, it overrides all of them, so I no longer get the defaults you had picked for things like the code block, the block quote, etc ... Any chance you can do a vim.tbl_deep_extend
to merge user choices with the standard ones?
Specifically, I lose these groups when I added the decorated ones. I'll just re-add these manually, but it would be nice to merge versus replace.
Looking good now! Next step for me is to link all of those highlight groups so I don't have hardcoded values as I switch themes often and would like colors that align with the theme I'm using. But coincidentally your choices look good with my primary theme (minihues).
They even look good with my secondary theme (gruvbox-material)—save for the code block:
Specifically, I lose these groups when I added the decorated ones. I'll just re-add these manually, but it would be nice to merge versus replace.
You can just do something like vim.list_extend( require("markview").configuration.highlight groups, require("markview.presets").decorated_hls)
for that.
I submitted #24 which allows a user to use the established idiom of overriding default values via the setup function. One can override only a specific item, while still inheriting the rest of the defaults.
I submitted #24 which allows a user to use the established idiom of overriding default values via the setup function. One can override only a specific item, while still inheriting the rest of the defaults.
This is not intended behavior. This works great when you are doing small tweaks to the plugin.
But when you try to use the setup function to actually set things up to your need you will have no way(without redefining them) to remove these default highlight groups.
Highlight groups should be maintained by the user as per their needs. And as such they should preferably be maintained by their colorscheme(or similar plugin) not individually by plugins(especially not this one since it doesn't rely on any of the defaults highlight groups). The option is there only for the sake of completeness.
Besides, you can just use vim.list_extend(markview.configuration.highlight groups, { your_list_of_highlights })
to do that.
What are your thoughts on this line from the PR?
Before I got the label headers working, when I wanted to use the default icon headers, I had to define all of them explicitly—even though I had no changes to heading_N—because I could not just set shift_width
. Doing so with a shallow extend wiped out your defaults. Thanks.
What are your thoughts on this line from the PR?
Before I got the label headers working, when I wanted to use the default icon headers, I had to define all of them explicitly—even though I had no changes to heading_N—because I could not just set
shift_width
. Doing so with a shallow extend wiped out your defaults. Thanks.
The plugin originally used tbl_deep_extend
but there's a problem. You lose the ability to disable parts of the plugin.
Some of the options use nested tables for their configuration and deep extend will result in inconsistent behavior (due to properties set by the plugin getting into places you don't want them).
Plus, some of the options use the hl
property which will cause an issue because now you have to explicitly define all the color related properties(as they will otherwise use hl
instead).
On a tangential note, I really like how my headings stack when using nvim-treesitter-context. In the prior markdown plug-in I used, the formatting of the header reverted back to plain text. But, with your plug-in, the formatting stays, so it looks very nice. Here is a small movie to demonstrate.
https://github.com/OXY2DEV/markview.nvim/assets/747855/64d0d6c9-e654-4311-a595-e7f3af3c3ff9
Can you share a working configuration that would produce this style of headings? I've been trying different permutations from the wiki page, but I'm getting various errors and cannot figure out the secret incantation I'm supposed to be doing. Ideally, if I could add an icon to the front of those headings as well (without the shift_width), it would be perfect.
On the wiki, there is this example:
But it fails with "attempt call field 'position' (nil value)". Any help would be appreciated as I really like the design choices you have made here. It looks lovely and as one that spends most of my time taking notes in markdown, I appreciate all your efforts!