Lsp: Syntax coloring in preview popup

Created on 19 Nov 2020  路  10Comments  路  Source: sublimelsp/LSP

Hi,

Currently there is no syntax coloring in preview popup (when you hover a type with the mouse)

image

documentation questioheldebug

Most helpful comment

Actually, I've just realized something that might be the reason this doesn't work.

Even if the server properly specifies that this block should be rendered in certain syntax, the markdown library that we are using has a hardcoded list of languages and syntaxes that it supports. Since your syntax is something custom and likely not in that list, it likely is the reason why it doesn't work.

The list is here: https://github.com/facelessuser/sublime-markdown-popups/blob/master/st3/mdpopups/st_mapping.py

You can customize the list with this setting: https://facelessuser.github.io/sublime-markdown-popups/settings/#mdpopupssublime_user_lang_map

You just need to figure out the language identifier that this server is using (but it's probably zig).

All 10 comments

Hello,
Can you open up that file, and open the sublime console(ctrl+`) and type view.settings().get('syntax'). And copy paste the result you got?

I get:

>>> view.settings().get('syntax')
'Packages/Zig.tmLanguage'

It's up to the server how it "formats" the code it sends (more precisely, how it specifies that the content should be formatted). So it's likely just the server's "fault" here.

Which server is that? Is it open source? If yes then you should probably report this over in its repo.

Thanks @rchl i have reported the issue on the server repo https://github.com/zigtools/zls/issues/196

Actually, I've just realized something that might be the reason this doesn't work.

Even if the server properly specifies that this block should be rendered in certain syntax, the markdown library that we are using has a hardcoded list of languages and syntaxes that it supports. Since your syntax is something custom and likely not in that list, it likely is the reason why it doesn't work.

The list is here: https://github.com/facelessuser/sublime-markdown-popups/blob/master/st3/mdpopups/st_mapping.py

You can customize the list with this setting: https://facelessuser.github.io/sublime-markdown-popups/settings/#mdpopupssublime_user_lang_map

You just need to figure out the language identifier that this server is using (but it's probably zig).

Thanks i will give that a try, and maybe an opportunity for me to send a PR to support zig over there out of the box (there is a plugin for zig syntax https://github.com/ziglang/sublime-zig-language)

I don't understand what i have to put in my settings file

    "mdpopups.sublime_user_lang_map": {
        "zig": [ ["zig"], ["Zig"] ]
    },

This doesn't work

The identifier is Zig

image

You have to specify the path to the syntax file. Something like that:

    "mdpopups.sublime_user_lang_map": {
        "zig": [ ["zig"], ["Zig/Zig"] ]
    },

Although that path doesn't look correct to me. Check the exact path to the syntax file with https://github.com/sublimelsp/LSP/issues/1472#issuecomment-730650277 and put it here, skipping the Packages/ and the file extension parts.

I was using my local package, i reinstalled everything from the package manager, and now it works

    "mdpopups.sublime_user_lang_map": {
        "zig": [ ["zig"], ["Zig Language/Syntaxes/Zig"] ]
    },

Thanks for the help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olegbl picture olegbl  路  5Comments

lsmenicucci picture lsmenicucci  路  3Comments

predragnikolic picture predragnikolic  路  7Comments

tomv564 picture tomv564  路  4Comments

ryanpcmcquen picture ryanpcmcquen  路  4Comments