nvim-orgmode / orgmode

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

Links inside bullet lists are not highlighted and concealed #316

Closed sarmong closed 2 years ago

sarmong commented 2 years ago

Describe the bug

When I put a link into a bullet list, it is not recognized by treesitter or syntax

Steps to reproduce

  1. Add the following lines to org file

    - [[github.com][GitHub]]
    
    [[github.com][GitHub]]
  2. Observe first line not being highlighted and concealed

Expected behavior

Links inside bullet lists are parsed correctly

Emacs functionality

In default doom-emacs config this works as expected

Minimal init.lua

vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.cmd([[set packpath=/tmp/nvim/site]])

local package_root = "/tmp/nvim/site/pack"
local install_path = package_root .. "/packer/start/packer.nvim"

local function load_plugins()
    require("packer").startup({
        {
            "wbthomason/packer.nvim",
            { "nvim-treesitter/nvim-treesitter" },
            { "kristijanhusak/orgmode.nvim", branch = "master" },
        },
        config = {
            package_root = package_root,
            compile_path = install_path .. "/plugin/packer_compiled.lua",
        },
    })
end

_G.load_config = function()
    print("LOADINGCONFIG")
    require("orgmode").setup_ts_grammar()
    require("nvim-treesitter.configs").setup({})

    vim.cmd([[packadd nvim-treesitter]])
    vim.cmd([[runtime plugin/nvim-treesitter.lua]])
    vim.cmd([[TSUpdateSync org]])

    -- Close packer after install
    if vim.bo.filetype == "packer" then
        vim.api.nvim_win_close(0, true)
    end

    require("orgmode").setup()

    -- Reload current file if it's org file to reload tree-sitter
    if vim.bo.filetype == "org" then
        vim.cmd([[edit!]])
    end
end

if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system({ "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path })
end
load_plugins()
require("packer").sync()
vim.cmd([[autocmd User PackerCompileDone ++once lua load_config()]])

vim.opt.conceallevel = 3
vim.opt.concealcursor = "nc"

Screenshots and recordings

image

OS / Distro

Arch Linux

Neovim version/commit

v0.8.0-dev

Additional context

No response

kristijanhusak commented 2 years ago

To get proper link concealing everywhere you need to use treesitter highlights. I updated minimal init to enable that by default now https://gist.github.com/kristijanhusak/a0cb5f4eb2bad3e732a1d18d311ebe2f

sarmong commented 2 years ago

Unfortunately, it didn't help

kristijanhusak commented 2 years ago

I cannot reproduce it with minimal init. Give it another the latest one https://gist.github.com/kristijanhusak/a0cb5f4eb2bad3e732a1d18d311ebe2f

sarmong commented 2 years ago

Just to be clear:

  1. I create this config
  2. Run nvim -u init.lua test.org
  3. Add the lines I wrote above
  4. Do :set conceallevel=2
  5. And first line is not concealed, whereas the first one is.

Do you have both lines concealed?

kristijanhusak commented 2 years ago

Yes. Make sure you are using latest minimal init from the link I provided in previous comment, since I updated it when you reported this.

sarmong commented 2 years ago

Here's a screen recording

https://0x0.st/oBt6.mp4

https://user-images.githubusercontent.com/42828375/171216837-0449669f-5001-4255-b9f9-5d93d84a8deb.mp4

sarmong commented 2 years ago

Tested on 0.7 - same result

jgollenz commented 2 years ago

@sarmong I can't open that video, Github says the file is corrupted.

I also tried with the minimal init and the concealing works as expected for me.

kristijanhusak commented 2 years ago

For me it happens randomly, but only if I use same minimal init every time. If i comment out packer installation every time, and just use what's already installed, it doesn't happen at all. @sarmong is this happening with your regular configuration? If you have treesitter highlights set up it should work fine.

sarmong commented 2 years ago

@jgollenz , please use chromium to watch the video. It doesn't for in Firefox for me either

sarmong commented 2 years ago

@kristijanhusak , yes, it is happening with my regular configuration. You can see treesitter config here

When I comment out the disable = {'org'}, conceal stops working completely in my config for some reason

kristijanhusak commented 2 years ago

@sarmong Can you try to put require("orgmode").setup_ts_grammar() in the same file before line 4, and remove disable = {'org'} + run the :TSUpdate org?

sarmong commented 2 years ago

Same result.

And when I ran ;TSUpdate org - it said that all parsers were up-to-date.

Btw, shouldn't it be disabled as per Readme? If it's enabled, then both treesitter and regex highlighting run at the same time?

kristijanhusak commented 2 years ago

Readme is a bit outdated, since treesitter highlights now supports most of the things that were not available before. These settings should work fine:

  highlight = {
    enable = true,
    additional_vim_regex_highlighting = { 'org' },
  },

Treesitter has bigger priority over regex syntax hl, so it will highlight treesitter, and what's left with syntax highlighting.

sarmong commented 2 years ago

If I do this in the minimal config, I do get the expected result as well. Which might make sense, because treesitter loads befor PackerCompileDone and loads without the right configuration. However, it's weird, that it doesn't work in my config

- vim.cmd([[autocmd User PackerCompileDone ++once lua load_config()]]
+ load_config()
sarmong commented 2 years ago

I found the reason. I wasn't properly loading orgmode config. Sorry for taking your time.

petRUShka commented 9 months ago

@sarmong what was the reason?

sarmong commented 9 months ago

@petRUShka man, I have no idea, it's been 1.5 years and I no longer use the plugin.