nvim-navic icon indicating copy to clipboard operation
nvim-navic copied to clipboard

Invalid order function for sorting with long css line

Open Rolv-Apneseth opened this issue 1 year ago • 2 comments

So apologies if this has been explained elsewhere, or this is not an issue with this plugin as it seems, but I couldn't find any reference to it. I am having a minor issue when editing minimized css files (i.e. the whole file is on a single line). The error given is:

Error executing vim.schedule lua callback: ...ite/pack/packer/start/nvim-navic/lua/nvim-navi
c/init.lua:77: invalid order function for sorting

No error is given and the plugin works as expected on regular css files where all the code is on separate lines. I am using the default setup options if that makes any difference, and am displaying it using:

vim.o.winbar = "%{%v:lua.require'nvim-navic'.get_location()%}"

Now, this is not major because this plugin isn't the most useful for css files anyways so I can just not attach it when the language server is cssls and then of course no error shows up. If there is however a way to fix this, perhaps you could point me in the right direction and I could put in a pr for it?

Rolv-Apneseth avatar Sep 12 '22 10:09 Rolv-Apneseth

Forgot to provide an example sorry, here is code that causes this issue for me (random example of a minified css file)

Rolv-Apneseth avatar Sep 12 '22 11:09 Rolv-Apneseth

Got the same error in a html file. Here is the full stacktrace:

Error executing vim.schedule lua callback: ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:77: invalid order function for sorting                                                                                           
stack traceback:                                                                                                                                                                                                                        
        [C]: in function 'sort'                                                                                                                                                                                                         
        ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:77: in function 'symbolInfo_treemaker'                                                                                                                              
        ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:175: in function 'parse'                                                                                                                                            
        ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:187: in function 'handler'                                                                                                                                          
        ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:21: in function 'callback'                                                                                                                                          
        ....mount_nvimOX6Kh7/usr/share/nvim/runtime/lua/vim/lsp.lua:1958: in function 'handler'                                                                                                                                         
        ....mount_nvimOX6Kh7/usr/share/nvim/runtime/lua/vim/lsp.lua:1390: in function ''                                                                                                                                                
        vim/_editor.lua: in function <vim/_editor.lua:0>   

smjonas avatar Sep 15 '22 13:09 smjonas

Hmm.. Seems that sorting function can be improved.. @smjonas Can you share the html code that triggers this issue?

SmiteshP avatar Sep 18 '22 10:09 SmiteshP

Hmm.. Seems that sorting function can be improved.. @smjonas Can you share the html code that triggers this issue?

I cannot, unfortunately (I was not able to reduce the HTML in a reasonable amount of time such that it does not contain sensitive data while still triggering the error). Maybe the CSS that @Rolv-Apneseth provided helps?

smjonas avatar Sep 18 '22 18:09 smjonas

Hi @SmiteshP, I've also got the same error in a html files. It's a sendmail's libmilter's document which can be downloaded in this website. Download the sendmail-current.tar.gz, untar it and open the libmilter/docs/api.html will get the error.

Here's my error log:

Error executing vim.schedule lua callback: ...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:77: invalid order function for sorting
stack traceback:
	[C]: in function 'sort'
	...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:77: in function 'symbolInfo_treemaker'
	...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:175: in function 'parse'
	...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:187: in function 'handler'
	...ite/pack/packer/start/nvim-navic/lua/nvim-navic/init.lua:21: in function 'callback'
	/usr/local/share/nvim/runtime/lua/vim/lsp.lua:1956: in function 'handler'
	/usr/local/share/nvim/runtime/lua/vim/lsp.lua:1389: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

And my nvim-navic's config (using packer.nvim):

    use({
      "SmiteshP/nvim-navic",
      requires = "neovim/nvim-lspconfig",
      config = function()
        require("nvim-navic").setup({
          highlight = true,
        })
      end,
    })

And my neovim's :version

:version
NVIM v0.8.0-dev-1003-ga62cb406b1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-
prototypes -std=gnu99 -Wshadow -Wconversion -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-c
ommon -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/code/neovim/build/cmake.config -I/co
de/neovim/src -I/code/neovim/.deps/usr/include -I/usr/include -I/code/neovim/build/src/nvim/auto -I/code/neovim/build/include
Compiled by root@vbm

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

mars90226 avatar Sep 23 '22 09:09 mars90226