halfbrained / cuda_lsp

LSP Client plugin for CudaText
6 stars 4 forks source link

we need the option to specify several lexer names per one server #43

Closed Alexey-T closed 3 years ago

Alexey-T commented 3 years ago

eg for HTML server users may need to set N lexers for 1 server:

HTML PHP and Screenshot from 2021-04-13 00-49-42

so lang_ids is not needed, let user write this mapping!

lang_ids = {
    'ABAP': 'abap',
    'Windows Bat': 'bat',
    'Batch files': 'bat',
    'BibTeX': 'bibtex',
    'Clojure': 'clojure',
    'Coffeescript': 'coffeescript',
    'C': 'c',
    'C++': 'cpp',
    'C#': 'csharp',
Alexey-T commented 3 years ago

it can be

{
    "lexers": ["HTML aa", "HTML bb", "HTML more"],
    "server_lang": "html",
    "cmd": ["/home/user/pathtoserver"]
}
halfbrained commented 3 years ago

I can do that, but for servers with multiple language ids (e.g. C,C++) you will need to create config file for each lang_id, since I am required to give lang_id of the document to server.

The other way - user adds mapping of 'lexer_name -> lang_id' somewhere; maybe a command like 'Set language id for current lexer'?

Alexey-T commented 3 years ago

it is Ok if users need to create 2 configs.

the 2nd way is ok too

Alexey-T commented 3 years ago

the 'mapping' lexername->langid is OK in 1 cfg file too, no?

halfbrained commented 3 years ago

the 'mapping' lexername->langid is OK in 1 cfg file too, no?

hm... how such a config would look like? I can't see a clear and nice way.

Alexey-T commented 3 years ago
{
  "lexers": {
     "onelexer": "id1",
     "twolexer": "id2"
    },
  //rest
}
halfbrained commented 3 years ago

yep... going with your format

halfbrained commented 3 years ago

new format

{
    // supported langids
    "langids": ["python"],
    // map additional non-default lexers to langids 
    "lexers": {
        "Rainbow python": "python"
    },
    // command to start LSP server
    "cmd": ["pyls"]
}
Alexey-T commented 3 years ago

первый ключ избыточен- можно его получить по всем значениям 'lexers' @halfbrained

halfbrained commented 3 years ago

Да, я сначала без первого сделал, но это:

{
    "langids": ["python"],
    "cmd": ["pyls"]
}

лучше этого мне кажется

{
    "lexers": {
        "Python": "python"
    },
    "cmd": ["pyls"]
}

кстати оба варианта сейчас работают... так что я могу либо написать в ридми, что 'lexers' и 'langids' взаимозаменяемы, либо убрать 'langids' из примера конфига, и упомянуть отдельно.

Alexey-T commented 3 years ago
{
    "lexers": {
        "Python": "python"
    },
    "cmd": ["pyls"]
}

это то что надо. потому что тут мы можем указать 2-3 лексера и 2-3 языка сервера

halfbrained commented 3 years ago

updated readme, no related code changes

https://github.com/halfbrained/cuda_lsp/commit/9d5419af2d3b3af9bb24f19547aa338eb5b040c6