nvim-orgmode / orgmode

Orgmode clone written in Lua for Neovim 0.9+.
https://nvim-orgmode.github.io/
MIT License
3.04k stars 134 forks source link

In week agenda view the tag are not shown fully #433

Closed Nithin745 closed 1 year ago

Nithin745 commented 1 year ago

Describe the bug

The tags on the heading are going beyond screen, had to scroll to the right to see the tags.

Steps to reproduce

open agenda to view the week agenda.

Expected behavior

Show the tags within the screen, i.e without need for horizontal scroll

Emacs functionality

No response

Minimal init.lua

n/a

Screenshots and recordings

Screenshot from 2022-10-30 01-36-55 Screenshot from 2022-10-30 01-37-04

OS / Distro

fedora 36

Neovim version/commit

0.9

Additional context

No response

jgollenz commented 1 year ago

@Nithin745 do you have set the org_tags_column option in in your config?

Nithin745 commented 1 year ago

@Nithin745 do you have set the org_tags_column option in in your config?

yes i set it to 50 and also checked with 20. still the look the same ` require('orgmode').setup{ org_agenda_files = {'/Public/orgmode/agenda/*', '/Public/orgmode/notes/*/'}, org_default_notes_file = '/Public/orgmode/notes/refile.org', org_capture_templates = { n = { description = 'Notes', template = '#+TITLE: %?\n#+DATE: %t\n', target = '~/Public/orgmode/notes/refile.org' } }, org_tags_column = 20 -- win_split_mode = {'float', .9} }

`

anton-fomin commented 1 year ago

I had the same problem and turning of the sign column helped. I end up with an autocommand for that

vim.api.nvim_create_autocmd("FileType", {
    pattern = "orgagenda",
    callback = function()
        vim.cmd[[
        set nornu
        set nonu
        set signcolumn=no
        ]]
    end
})
Nithin745 commented 1 year ago

vim.api.nvim_create_autocmd("FileType", { pattern = "orgagenda", callback = function() vim.cmd[[ set nornu set nonu set signcolumn=no ]] end })

Yes this works, but the left side contents too close to the edge of the screen, so turned on only the signcolumn now it looks much better. signcolumn=no Screenshot from 2022-10-30 18-03-39

signcolumn=yes Screenshot from 2022-10-30 18-03-10

jgollenz commented 1 year ago

set it to 50 and also checked with 20. still the look the same

My bad, this option does not influence how the tags are displayed in the agenda.

@anton-fomin @Nithin745 could you please try whether this also happens when you run neovim with the minimal config? nvim -u /path/to/orgmode/scripts/minimal_init.lua your-file.org

kristijanhusak commented 1 year ago

@anton-fomin @Nithin745 could you please try whether this also happens when you run neovim with the minimal config? nvim -u /path/to/orgmode/scripts/minimal_init.lua your-file.org

And also if it fixes itself if you press r to refresh the agenda?

Nithin745 commented 1 year ago

@anton-fomin @Nithin745 could you please try whether this also happens when you run neovim with the minimal config? nvim -u /path/to/orgmode/scripts/minimal_init.lua your-file.org

In the minimal config it is not happening, but i think (like @anton-fomin said) culprit is the sign column, because when i add the sign column to the minimal-config the tags are once again out of screen.

And also if it fixes itself if you press r to refresh the agenda?

Refreshing the agenda by pressing the r is also not working, when signcolumn is present in both my config and minimal-config

mininmal-config with signcolumn and relativenumbers Screenshot from 2022-10-30 22-25-41

mininmal-config without signcolumn

Screenshot from 2022-10-30 22-26-22

jgollenz commented 1 year ago

I've started looking into this. The issue is that we are only checking if the (rel)numbers column is present. What we should do instead is getting the whole gutter width with getwininfo().textoff, but unfortunately we are determining the content of the agenda (including the offset between agenda-items and their tags) before the window in question is even created. @kristijanhusak would there be a drawback to calling Agenda:open_window from Agenda:new or wherever suitable, as long as it is before we call e.g. AgendaView:new? We could then add another field win_width to store getwininfo().textoff, that we then pass to the views via the opts. This would also make the call to utils.winwidth for every agenda item obsolete.

edit: on that note, can we also use getwininfo().textoff in utils.winwidth?

kristijanhusak commented 1 year ago

@jgollenz I remember splitting things out for some reason, but I don't remember what was the reason. The only thing that crosses my mind is custom agenda commands that we plan to add in the future. Generally utils.winwidth seems invalid because it's not really checking the agenda window propeties, at least not on the initial open.

I think we should just disable all numbers/relativenumbers/signcolumn in the agenda view. Emacs doesn't render any of those, no matter the configuration that you have (tried relative numbers).

If you think there is some value to not override those, we can go with the solution to open the window before generating the data and use textoff for offset.

gerazov commented 1 year ago

This has troubled me for a while :sweat_smile: @anton-fomin's autocommand does the trick, but I also agree with @Nithin745 that with this it's visually displeasing as the content of the agenda is too close to the left edge. There is a break the text flow from the org file opened to the agenda.

So :+1: if it can be fixed without getting rid of the relative numbers an signs column. @jgollenz maybe check the getwininfo().textoff in the current org file and then use it for the Agenda? This would make the Agenda content align well with the org file content.

jgollenz commented 1 year ago

If you think there is some value to not override those

Well, personally I think the num and relnum columns are valuable, because I use them for vertical navigation. My agenda gets quite long sometimes and 17j beats pressing j seventeen times any day.

maybe check the getwininfo().textoff in the current org file

@gerazov I don't think this will be consistent. E.g. I have org files with thousands of lines, making the textoff value at least four, whereas the aganda has a couple of hundred lines tops (ok, vy almost exceeds 1k for me, but still), so the value would be three. The sign column itself also has no predictable width, as multiple plugins might use it. For instance, I do use gitsigns, which usually means that a sign column is present in the buffer of my org file, but it is not in the agenda buffer.

gerazov commented 1 year ago

But even if the margin is too large - at least the text in the Agenda will line up nicely with the text in the open buffer. This is :+1: for aesthetics :slightly_smiling_face:

gerazov commented 1 year ago

Actually atm with only the signs column turned off in the Agenda with the autocommand @anton-fomin suggested works ok - I can see the tags in their entirety :+1:

jgollenz commented 1 year ago

@Nithin745 @anton-fomin @gerazov

Please have a look at #444 and let me know if it fixes the issue

Nithin745 commented 1 year ago

@Nithin745 @anton-fomin @gerazov

Please have a look at #444 and let me know if it fixes the issue

Yes this fixes the issue in the agenda view, thank you Screenshot from 2022-11-14 10-38-16

Now even with the signcolumn ON the tags are displaying correctly.