ldelossa / litee.nvim

A framework for building Neovim plugins
409 stars 14 forks source link

No highlights #21

Open quantum-booty opened 2 years ago

quantum-booty commented 2 years ago

image I tried it with and without treesitter highlights (commented out).

require('calltree').setup({        -- where the calltree ui will spawn
    layout = "left",
    layout_size = 40,
    jump_mode = "invoking",
    icons = "nerd",
    -- icon_hls = {
    --     Folder = "TSNamespace",
    --     Reference = "TSParameterReference",
    --     Color = "TSType",
    --     Snippet = "TSType",
    --     Keyword = "TSType",
    --     Value = "TSType",
    --     Unit = "TSType",
    --     Text = "TSString",
    --     File = "TSURI",
    --     Module = "TSNamespace",
    --     Namespace = "TSNamespace",
    --     Package = "TSNamespace",
    --     Class = "TSType",
    --     Method = "TSMethod",
    --     Property = "TSMethod",
    --     Field = "TSField",
    --     Constructor = "TSConstructor",
    --     Enum = "TSType",
    --     Interface = "TSType",
    --     Function = "TSFunction",
    --     Variable = "TSConstant",
    --     Constant = "TSConstant",
    --     String = "TSString",
    --     Number = "TSNumber",
    --     Boolean = "TSBoolean",
    --     Array = "TSConstant",
    --     Object = "TSType",
    --     Key = "TSType",
    --     Struct = "TSType",
    --     Null = "TSType",
    --     EnumMember = "TSField",
    --     Struct = "TSType",
    --     Event = "TSType",
    --     Operator = "TSOperator",
    --     TypeParameter = "TSParameter",
    -- }
})
ldelossa commented 2 years ago

By default there are no highlights and by default most TS* highlight are not defined.

Try defining these highlights (change the colors to whatever you like):

"calltree
hi CTSymbol                 guifg=#87afd7 gui=underline
hi CTSymbolDetail           ctermfg=024 cterm=italic guifg=#988ACF gui=italic
hi CTSymbolJump             ctermfg=015 ctermbg=110 cterm=italic,bold,underline   guifg=#464646 guibg=#87afd7 gui=italic,bold
hi CTSymbolJumpRefs         ctermfg=015 ctermbg=110 cterm=italic,bold,underline   guifg=#464646 guibg=#9b885c gui=italic,bold
hi CTParameterReference     guifg=#4DC5C6 guibg=None
hi CTURI                    guifg=#988ACF guibg=None
hi CTNamespace              guifg=#87af87 guibg=None
hi CTMethod                 guifg=#0087af guibg=None
hi CTField                  guifg=#0087af guibg=None
hi CTConstructor            guifg=#4DC5C6 guibg=None
hi CTType                   guifg=#9b885c guibg=None
hi CTFunction               guifg=#988ACF guibg=None
hi CTConstant               guifg=#0087af guibg=None
hi CTString                 guifg=#af5f5f guibg=None
hi CTNumber                 guifg=#9b885c guibg=None
hi CTBoolean                guifg=#0087af guibg=None
hi CTConstant               guifg=#0087af guibg=None
hi CTOperator               guifg=#988ACF guibg=None
hi CTParameter              guifg=#988ACF guibg=None

Or you can use my colorscheme which I just pushed these values for: https://github.com/ldelossa/vimdark

quantum-booty commented 2 years ago

Ah I see! It would be nice to have a default set of highlight as fallback if they are not specified by the user or by the colorscheme.

ldelossa commented 2 years ago

@quantum-booty makes sense, I'll add a function which just uses my theme's highlights as the default set :+1:

ldelossa commented 2 years ago

add default highlights, give it a try.

quantum-booty commented 2 years ago

@ldelossa Looks like the default highlights doesn't work for me. image

I think I figured out why, so in this function:

function _setup_default_highlights() 
    local dark = {
        CTBoolean              = 'hi CTBoolean                guifg=#0087af guibg=None',
        CTConstant             = 'hi CTConstant               guifg=#0087af guibg=None',
        CTConstructor          = 'hi CTConstructor            guifg=#4DC5C6 guibg=None',
        CTField                = 'hi CTField                  guifg=#0087af guibg=None',
        CTFunction             = 'hi CTFunction               guifg=#988ACF guibg=None',
        CTMethod               = 'hi CTMethod                 guifg=#0087af guibg=None',
        CTNamespace            = 'hi CTNamespace              guifg=#87af87 guibg=None',
        CTNumber               = 'hi CTNumber                 guifg=#9b885c guibg=None',
        CTOperator             = 'hi CTOperator               guifg=#988ACF guibg=None',
        CTParameter            = 'hi CTParameter              guifg=#988ACF guibg=None',
        CTParameterReference   = 'hi CTParameterReference     guifg=#4DC5C6 guibg=None',
        CTString               = 'hi CTString                 guifg=#af5f5f guibg=None',
        CTSymbol               = 'hi CTSymbol                 guifg=#87afd7 gui=underline',
        CTSymbolDetail         = 'hi CTSymbolDetail           ctermfg=024 cterm=italic guifg=#988ACF gui=italic',
        CTSymbolJump           = 'hi CTSymbolJump             ctermfg=015 ctermbg=110 cterm=italic,bold,underline   guifg=#464646 guibg=#87afd7 gui=italic,bold',
        CTSymbolJumpRefs       = 'hi CTSymbolJumpRefs         ctermfg=015 ctermbg=110 cterm=italic,bold,underline   guifg=#464646 guibg=#9b885c gui=italic,bold',
        CTType                 = 'hi CTType                   guifg=#9b885c guibg=None',
        CTURI                  = 'hi CTURI                    guifg=#988ACF guibg=None',
    }
    local light = {
        CTBoolean               = 'hi CTBoolean                guifg=#005f87 guibg=None',
        CTConstant              = 'hi CTConstant               guifg=#005f87 guibg=None',
        CTConstructor           = 'hi CTConstructor            guifg=#9b885c guibg=None',
        CTField                 = 'hi CTField                  guifg=#005f87 guibg=None',
        CTFunction              = 'hi CTFunction               guifg=#806CCF guibg=None',
        CTMethod                = 'hi CTMethod                 guifg=#005f87 guibg=None',
        CTNamespace             = 'hi CTNamespace              guifg=#87af87 guibg=None',
        CTNumber                = 'hi CTNumber                 guifg=#9b885c guibg=None',
        CTOperator              = 'hi CTOperator               guifg=#806CCF guibg=None',
        CTParameter             = 'hi CTParameter              guifg=#806CCF guibg=None',
        CTParameterReference    = 'hi CTParameterReference     guifg=#268889 guibg=None',
        CTString                = 'hi CTString                 guifg=#af5f5f guibg=None',
        CTSymbol                = 'hi CTSymbol                 guifg=#806CCF gui=underline',
        CTSymbolDetail          = 'hi CTSymbolDetail           ctermfg=024 cterm=italic guifg=#005f87 gui=italic',
        CTSymbolJump            = 'hi CTSymbolJump             ctermfg=015 ctermbg=110 cterm=italic,bold,underline   guifg=#464646 guibg=#87afd7 gui=italic,bold',
        CTSymbolJumpRefs        = 'hi CTSymbolJumpRefs         ctermfg=015 ctermbg=110 cterm=italic,bold,underline   guifg=#464646 guibg=#9b885c gui=italic,bold',
        CTType                  = 'hi CTType                   guifg=#268889 guibg=None',
        CTURI                   = 'hi CTURI                    guifg=#806CCF guibg=None',
    }
    local bg = vim.api.nvim_get_option("background")
    if bg == "dark" then
        print("here - dark")
        for hl_name, hl in pairs(dark) do
            if not vim.fn.hlexists(hl_name) == 0 then
                vim.cmd(hl)
            end
        end
    end
    if bg == "light" then
        for hl_name, hl in pairs(light) do
            if vim.fn.hlexists(hl_name) == 0 then
                vim.cmd(hl)
            end
        end
    end
end

_setup_default_highlights()

looks like this:

  if not vim.fn.hlexists(hl_name) == 0 then
      vim.cmd(hl)
  end

should be this instead:

  if vim.fn.hlexists(hl_name) == 0 then
      vim.cmd(hl)
  end

And it would be nice to get rid of the debug print

print("here - dark")
ldelossa commented 2 years ago

yup!

ldelossa commented 2 years ago

Pushed some changes, give it a go.

quantum-booty commented 2 years ago

Pushed some changes, give it a go.

Thanks, working now!

fitrh commented 2 years ago

I have the same issue, using codicons gave me partial highlight, but no highlight with nerd

checking the value of LTFunction, LTType and LTFiled return correct values, but it does not apply to litee window

20220529_173946_full

20220529_174020_full

ttytm commented 2 years ago

@fitrh

I'm having the same issue, I thought of commenting here yesterday now you beat me to it 😊

Getting the correct highlight color codes returned, but no actual highlighting is happening. I tried to add fixed values for the highlights in the plugins corresponding files instead of using variables, but it looks like there is an issue with the colors getting applied in the panel. I also tried disabling tree sitter highlights to check for conflicts.

E.g., one of the goals was to change the indent lines color to something less bright.

ldelossa commented 2 years ago

We maybe only doing syntax matches for codicon icons and not nerd icons 😬. Im a bit wrapped up but i should be able to look into this soon. If you want to beat me too it, the issue most likely revolves around this function: https://github.com/ldelossa/litee.nvim/blob/f181c7674e8a826ef66d1f67f23e92631477bb7c/lua/litee/lib/util/window.lua#L13

ttytm commented 2 years ago

Unfortunately I can't spot the reason for this problem, so I did some exploratory testing and modifications around the highlight related functions for the last two hours, unfortunately without satisfying results.

What I can say is that the highlight groups get set up properly, but they won't get applied to the filetree elements. That is using any of the litee.lib icon sets default | nerd | codicons. The only thing in the filetree panel that has highlights are the devicons which come with the filetree itself.

Following are two mappings that print highlights of the element under cursor and might be of use when debugging highlights. I mapped them to some FKeys or this purpose:

local map = vim.keymap.set
-- ...
map( "n",  "<F6>", [[:echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#")<CR>]])
map("n", "<F7>", "<cmd>TSHighlightCapturesUnderCursor<CR>")
fitrh commented 2 years ago

Configuring tree.icon_set for litee.lib fixed this issue

diff --git a/lua/config/plugin/litee/setup.lua b/lua/config/plugin/litee/setup.lua
index 2b1a243..98c70ec 100644
--- a/lua/config/plugin/litee/setup.lua
+++ b/lua/config/plugin/litee/setup.lua
@@ -1,4 +1,12 @@
 require("litee.lib").setup({
+  tree = {
+    icon_set_custom = {
+      Collapsed = "",
+      Expanded = "",
+      IndentGuide = " ",
+    },
+    icon_set = "nerd",
+  },
   panel = {
     orientation = "right",
     panel_size = math.ceil(vim.api.nvim_get_option("columns") / 4),

But it seems I still need to set the icon_set for the plugins, so my complete config now looks like this

require("litee.lib").setup({
  tree = {
    icon_set_custom = {
      Collapsed = "",
      Expanded = "",
      IndentGuide = " ",
    },
    icon_set = "nerd",
  },
  panel = {
    orientation = "right",
    panel_size = math.ceil(vim.api.nvim_get_option("columns") / 4),
  },
})

require("litee.symboltree").setup({
  icon_set = "nerd",
  hide_cursor = false,
  on_open = "panel",
  keymaps = { hide = "q" },
})

require("litee.calltree").setup({
  icon_set = "nerd",
  hide_cursor = false,
  on_open = "panel",
  keymaps = { hide = "q" },
})

I don't know if this is the expected behavior because in the first place I thought the plugins would inherit the litee.lib configuration